@tonton81 I'm sure you tested FlexCan on a Teensy MicroMod, but I am having trouble getting it to work on both the SkarkFun MM ATP board with an external transceiver as well as a custom carrier board.
I have a T4.1 set up to print out anything it recieves.
If I transmit from a T4.0 it work. If I transmit from a TMM it doesn't.
Here is the sketch I am using on the Teensy MM:
Code:
#include <FlexCAN_T4.h>
FlexCAN_T4<CAN3, RX_SIZE_256, TX_SIZE_16> Can0;
void setup(){
while (!Serial && millis() < 5000);
Serial.begin(115200);
delay(1000);
Serial.print(CrashReport);
Can0.begin();
Can0.setBaudRate(500000);
Can0.enableMBInterrupts();
Can0.onReceive(canSniff);
Serial.println("FlexCAN ready");
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop(){
Can0.events();
canSend();
delay(500);
digitalWrite(13, HIGH);
delay(500);
}
void canSend(){
CAN_message_t msgTx, msgRx;
msgTx.buf[0] = 0x07;
msgTx.buf[1] = 0x22;
msgTx.buf[2] = 0xf4;
msgTx.buf[3] = 0x0b;
msgTx.buf[4] = 0x20;
msgTx.buf[5] = 0x2a;
msgTx.buf[6] = 0x10;
msgTx.buf[7] = 0xc0;
msgTx.len = 8; // number of bytes in request
msgTx.flags.extended = 0; // 11 bit header, not 29 bit
msgTx.flags.remote = 0;
msgTx.id = 0x7E0; // request header for OBD
msgTx.seq = 0;
Can0.write(msgTx);
digitalWrite(13, LOW);
}
void canSniff (const CAN_message_t &msg){
digitalWrite(13, LOW);
Serial.println(" ");
Serial.print("MB: ");
Serial.print(msg.mb);
Serial.print(" ID: 0x");
Serial.print(msg.id, HEX);
Serial.print(" EXT: ");
Serial.print(msg.flags.extended);
Serial.print(" LEN: ");
Serial.print(msg.len);
Serial.print(" DATA: ");
for (uint8_t i = 0; i < 8; i++)
{
Serial.print(msg.buf[i]);
Serial.print(" ");
}
}
Would you be able to run a test on your side?
EDIT: I can confirm CAN2 works on the MicroMod. But not CAN3.