tonton81 / FlexCAN_T4

FlexCAN (CAN 2.0 / CANFD) Library for Teensy 3.x and 4.0
https://forum.pjrc.com/threads/56035-FlexCAN_T4-FlexCAN-for-Teensy-4
MIT License
196 stars 66 forks source link

CAN maximum baudrate #23

Closed jimmie11 closed 1 year ago

jimmie11 commented 3 years ago

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.

My 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/
tonton81 commented 3 years ago

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

jimmie11 commented 3 years ago

Thank you.

I configured the sensor for 500 kbps then used the following code but still no response.

  can1.begin();
  can1.setClock(60);
  can1.setBaudRate(500000);   //250000
designer2k2 commented 3 years ago

Running a teensy 4,0 here with the 24MHz default clock. Read / send with 500kbps is no problem for me.

jimmie11 commented 3 years ago

Thank you @designer2k2. Yes, I am also confirming it.

It depends on both the sensor AND the hardware on the MCU side. Basically the existence a 60 Ohm resistor across the CAN lines (on both sides, sensor and MCU).

tonton81 commented 3 years ago

you can get away with resistor less 125kbps or below, but any higher requires it mandatory to function