cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Communication: Baud Rate Configuration

KMew
Senior III

Hello,

I have read the reference manual but the terminology used in the .ioc file and the reference manual do not align, so I am getting confused.

I am using the STM32H7B3I-EVAL evaluation board, which uses a STM32H7B3LIH6Q MCU. According to the datasheet, that has a clock frequency of 280 MHz. I am trying to configure the CAN protocol's baud rate and I need to determine what to set the parameters to. Specifically:

  • NominalPrescaler/DataPrescaler
  • NominalSyncJumpWidth/DataSyncJumpWidth
  • NominalTimeSeg1/DataTimeSeg1
  • NominalTimeSeg2/DataTimeSeg2

Based on what I've read online, I used this website to do my bit timing calculation:

http://www.bittiming.can-wiki.info/

I want to run a 500 kBit/s baud rate for my example. I would like to verify my steps:

Step 1: Determine FDCAN clock frequency

  • For this, I went to the .ioc file and it says the FDCAN clock is 280 MHz (Proof: Picture FDCAN_Ex)

Step 2: Use bit timing calculation website:

0693W00000UoNDcQAN.png 

Step 3: Define hfdcan1.Init parameters in code:

0693W00000UoNEaQAN.png 

Based on this, have I configured this properly for 500 kBit/s? Do I have the nominal sync jump width used correctly? (I don't see a mention of sync jump width on the website).

If I have made any mistakes, I would appreciate some feedback! (Please note that I do not have an oscilloscope access at this moment, which is why I'm asking here first).

1 ACCEPTED SOLUTION

Accepted Solutions
KMew
Senior III

I have figured out the problem.

It is not related to the baud rate. Instead, it is linked to two things:

1) In the .ioc file, the FDCAN TX/RX pins were set to PB8/9 by default. The previous FDCAN_Loopback test code assigns it to the proper pins (PA11/12). I switched it to PA11/12 in the .ioc file.

2) The jumper (JP38) on the evaluation board was not installed. I put a pin there, which means there is now a 120 ohm resistor on both ends.

Doing both solved the issue.

View solution in original post

5 REPLIES 5
KMew
Senior III

0693W00000UoNFOQA3.pngSorry, the image for the .ioc clock frequency did not send.

STM32Cube_FW_H7_V1.10.0\Projects\STM32H7B3I-EVAL\Examples\FDCAN\FDCAN_Loopback\Src\main.c

They set up a PLL to source the FDCAN clock

Yours at 280 MHz would need a prescaler or 14 to get to 20 MHz

  /* Bit time configuration:
    ************************
    Bit time parameter         | Nominal      |  Data
    ---------------------------|--------------|----------------
    fdcan_ker_ck               | 20 MHz       | 20 MHz
    Time_quantum (tq)          | 50 ns        | 50 ns
    Synchronization_segment    | 1 tq         | 1 tq
    Propagation_segment        | 23 tq        | 1 tq
    Phase_segment_1            | 8 tq         | 4 tq
    Phase_segment_2            | 8 tq         | 4 tq
    Synchronization_Jump_width | 8 tq         | 4 tq
    Bit_length                 | 40 tq = 2 µs | 10 tq = 0.5 µs
    Bit_rate                   | 0.5 MBit/s   | 2 MBit/s
  */
  hfdcan.Init.NominalPrescaler = 0x1; /* tq = NominalPrescaler x (1/fdcan_ker_ck) */
  hfdcan.Init.NominalSyncJumpWidth = 0x8;
  hfdcan.Init.NominalTimeSeg1 = 0x1F; /* NominalTimeSeg1 = Propagation_segment + Phase_segment_1 */
  hfdcan.Init.NominalTimeSeg2 = 0x8;
  hfdcan.Init.DataPrescaler = 0x1;
  hfdcan.Init.DataSyncJumpWidth = 0x4;
  hfdcan.Init.DataTimeSeg1 = 0x5; /* DataTimeSeg1 = Propagation_segment + Phase_segment_1 */
  hfdcan.Init.DataTimeSeg2 = 0x4;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello Tesla,

Thank you for the reply!

I did see this configuration, but I was thrown off because the PLL in my .ioc file is 280 MHz. So would that not change the values above? Is fdcan_ker_ck different than the PLL1Q (FDCAN) in my .ioc file?

KMew
Senior III

I have figured out the problem.

It is not related to the baud rate. Instead, it is linked to two things:

1) In the .ioc file, the FDCAN TX/RX pins were set to PB8/9 by default. The previous FDCAN_Loopback test code assigns it to the proper pins (PA11/12). I switched it to PA11/12 in the .ioc file.

2) The jumper (JP38) on the evaluation board was not installed. I put a pin there, which means there is now a 120 ohm resistor on both ends.

Doing both solved the issue.

KMew
Senior III

To further clarify, the bit timing calculator worked as intended.