Hi guys,
sorry for the delay but COVID makes things so hectic at work that it's hard to find the energy for anything more.
So I've tried a new setup and I still keep failing.
Here's my new setup. It's a completely new Teensy (the transceivers are the same).





I've used the following code:
Code:
#include <FlexCAN_T4.h>
const int ledPin = 13;
FlexCAN_T4<CAN1, RX_SIZE_256, TX_SIZE_16> myCan1;
FlexCAN_T4<CAN2, RX_SIZE_256, TX_SIZE_16> myCan2;
FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> myCan3;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
myCan1.begin();
myCan2.begin();
myCan3.begin();
myCan1.setBaudRate(250*1000);
myCan2.setBaudRate(250*1000);
myCan3.setBaudRate(250*1000);
}
void loop() {
// put your main code here, to run repeatedly:
CAN_message_t msg, rmsg;
msg.len=8;
msg.id=1;
msg.buf[0]=1;
msg.buf[1]=2;
msg.buf[2]=3;
msg.buf[3]=4;
msg.buf[4]=5;
msg.buf[5]=6;
msg.buf[6]=7;
msg.buf[7]=8;
myCan1.write(msg);
msg.id=2;
myCan2.write(msg);
msg.id=3;
myCan3.write(msg);
if ( myCan1.read(rmsg) )
{
Serial.print("CAN1 ");
Serial.print(" ID: 0x"); Serial.print(rmsg.id, HEX );
}
if ( myCan2.read(rmsg) )
{
Serial.print("CAN2 ");
Serial.print(" ID: 0x"); Serial.print(rmsg.id, HEX );
}
Serial.println ("Hi!");
digitalWrite(ledPin, !digitalRead(ledPin));
delay (500);
}
Neither controller returns a message information.
What am I doing wrong? Can it be the library? I know that this library works with the MCP2551 unit as I was able to send CAN data from a PC to Teensy using this lib.
Wiring seems ok. I've used full rod cables previously but have switched to those seen in the photos as the original ones weren't colour coded.
Do I need to take out the oscilloscope? If so what should I be looking for? Should data transfers bee only visible on Tx when there are no CAN_L and CAN_H cables connected?
Thanks for any help you can spare.
Cheers,
Rafał Typiak