2022-10-19 12:33 PM
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:
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
Step 2: Use bit timing calculation website:
Step 3: Define hfdcan1.Init parameters in code:
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).
Solved! Go to Solution.
2022-10-20 10:56 AM
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.
2022-10-19 12:34 PM
Sorry, the image for the .ioc clock frequency did not send.
2022-10-19 12:48 PM
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;
2022-10-19 12:52 PM
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?
2022-10-20 10:56 AM
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.
2022-10-20 10:59 AM
To further clarify, the bit timing calculator worked as intended.