Teensy 4.1 CAN max baud rate using FlexCAN_T4

Status
Not open for further replies.

jimmie

Well-known member
This is my first ever project using the CAN bus. I am interfacing a CAN sensor to a Teensy 4.1 and the FlexCAN_T4 library.

That sensor can be configured with CAN baudrates of up to 1000 kbps. In my application, I need to use the fastest possible CAN baudrate.

My program works fine up to a CAN baudrate of 250 kbps which is unfortunately too slow in my case. Once I bump the sensor CAN rate beyond 250 kbps (options are 500, 1000), the Teensy4.1 stops receiving data.

Is there any way to bump the CAN baudrate on the Teensy4.1? Is this a hardware or a software limitation?

BTW, I am using the following board:

http://copperhilltech.com/teensy-4-1-triple-can-bus-board-with-240x240-lcd-and-ethernet/

Thanks in advance for the community's help.
 
1000 does work, maybe the clock timings are different for your application (device your connected to), try changing the clock? can.setClock(clock speed) then run setBaudRate again, default is 24, you can try 60mhz and check it
 
Thank you tonton81 for responding to my question and for your time and effort in making the library.

I configured the sensor for 500 kbps then used the following code

Code:
  can1.begin();
  can1.setClock(60);
  can1.setBaudRate(500000);   //250000

But still, no response from the Teensy4.1.

Please tell me what else I can try?
 
you need to use setClock(CLK_60MHz);

also make sure your line terminations on CAN are correct or it may not work at all speeds
 
Thank you.

Just tried it but still, selecting a CAN baudrate > 250 kbps leads to no data received on the Teensy4.1. Selecting 250kbps works.

My code now reads:

Code:
  can1.begin();
  can1.setClock(CLK_60MHz);
  can1.setBaudRate(500000);
 
you checked your line terminations? i assume the sensor doesnt have one?

i can connect a car sensor directly to t4 and it works at 125kbps as well, doesn't mean the higher speeds will work :)
 
should be a 120 ohm resistor on CANH accross CANL at both furthest ends of the bus. if you have only 2 devices then put 120 ohm resistor at the sensor side and one at teensy side:

CANH <--> 120 ohm resistor <--> CANL

For a very short cable, a single 120 ohm resistor would normally work. But may not be needed depending on propagation delay compared to your transfer rate.

For short cables, you can often get by without any termination unless the baudrate is very high.
 
I am looking at the Teensy CAN board specs, and it says it has: 120 Ohm termination resistors. Do I still need the 60 Ohm resistor on the Teensy board side?
 
if it has it then no, you can verify the resistance of the line with a multimeter on CANH and CANL, it should show about 60 ohms if both sides have 120 ohm resistors
 
THANK YOU.

The problem was solved by following your advice and putting a 120 Ohm resistor on the sensor side between the CAN_H and _L lines.
 
Status
Not open for further replies.
Back
Top