Teensy 4.1 and CanBus

Hi tonton81. maybe the best approach is if you have or could point me to code examples using the Teensy 4.1 CanFD that include the filtering? just unsure how to use your .h file correctly. thanks boothby
 
Code:
Can0.setMBFilter(REJECT_ALL); // you must first block all frames from being captured (blacklist)

  Can0.enableMBInterrupts(); // enable all reception interrupts
  Can0.onReceive(canSniff); // set your callback
  Can0.setMBFilter(MB0,0x123); // start receiving only 0x123 (whitelist)
  Can0.setMBFilter(MB1,0x456); // also receive 0x456 (whitelist)

it should be same functions in both CAN2.0 and CANFD
 
tonton81.

success. your lines of code as conformation of what i thought reading through the FlexCAN_T4. and why i didn't find your description file on GitHub on that file till today... very helpful.
one of my big issues i added a line of code that printed to serial port 1 which was not initialized. never noticed till this afternoon wondering what that print statement didn't show up on the terminal. Serial1.print that is why i only got 5 calls to the CanSniff() then stopped.
Notice i could not use MB4,5,6 for assigning the mailbox interrupt. not sure why. using your mailboxStatus() showed 7 RX and 7 TX.

question on the hardware. i notice when the sending ID didn't match with the destination, there was still an ack back to the sender. is that correct? would think that the node sending would only received if there was a node matching that ID.

Thanks so much for your help.
Boothby
 
it is similar i guess to UDP, a broadcast that all nodes see. Hardware wise, all nodes will ack the frame itself, but only the specific node will actually reply if it was programmed to do so.

As you check out mailboxStatus you will see some mailboxes as Standard and some as Extended. Keep in mind 0x456 is a standard ID and if lets say MB7 is an Extended mailbox, it will technically receive only extended frames of id 0x456, and a standard frame of same ID is rejected
 
Good afternoon guys. I am using the triplecan board with a teensy 4.0. I am having major issues with 5000000. I can go up to 4000000, and I have changed the speed to 60Mhz, but if I go to my target speed I get nothing. I was wondering if I am missing something basic. I can post my code tonight, I am away from my laptop but wanted to throw the question out as its pretty much the demo from this link…

https://github.com/skpang/Teensy40_triple_CAN_demo/blob/master/Teensy40_triple_CAN_demo.ino

I know this thread is old, but it was all I could find in reference to 5Mb
 
Hi, I am a new student trying to figure out how to make a code that sends out simple can fd messages to a single teensy 4.1 microcontroller. I need help with a sample code that can do this as the example codes I run. come back with many compilation errors and they are not clear and concise. Also, I want to further move my project to matlab.
 
Back
Top