Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 11 of 11

Thread: Teensy 4.1 CAN max baud rate using FlexCAN_T4

  1. #1
    Senior Member
    Join Date
    Jun 2017
    Posts
    137

    Teensy 4.1 CAN max baud rate using FlexCAN_T4

    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...-and-ethernet/

    Thanks in advance for the community's help.

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,832
    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

  3. #3
    Senior Member
    Join Date
    Jun 2017
    Posts
    137
    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?

  4. #4
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,832
    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

  5. #5
    Senior Member
    Join Date
    Jun 2017
    Posts
    137
    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);

  6. #6
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,832
    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

  7. #7
    Senior Member
    Join Date
    Jun 2017
    Posts
    137
    The sensor has an 8-pin plug. Two of the pins are Can_H, Can_L and then Gnd. Those 3 contacts are wired into the Teensy board using 6-in wires.

    The board I am using is the SKpang board:

    http://copperhilltech.com/teensy-4-1...-and-ethernet/

    Where would the terminations be? I am happy to try anything.

    Thank you.

  8. #8
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,832
    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.

  9. #9
    Senior Member
    Join Date
    Jun 2017
    Posts
    137
    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?

  10. #10
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,832
    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

  11. #11
    Senior Member
    Join Date
    Jun 2017
    Posts
    137
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •