Skip to content
geier99 edited this page Jan 22, 2022 · 10 revisions

Welcome to the fdcanBitrateCalculatorSTM32G4 wiki!

FDCAN Bitrate calculations

This tool will help you to calculate the FDCAN bitrates for STM32 family und using STM32CubeIDE (STM32CubeMX)

It can be used for calculationg the nominal bit time and data bit time. However, you need to be careful what you want to calculate because the maximum values of some parameters are different.

nominal bit time parameter range

  • NBRP[8:0]: Bit rate prescaler (Valid values are 0 to 511.) In the Excelsheet I am using 1 to 512 (faktor, prescaler)
  • NTSEG1[7:0]: Nominal time segment before sample point. (Valid values are 0 to 255). In the Excelsheet I am using 1 to 256
  • NTSEG2[6:0]: Nominal time segment after sample point. (Valid values are 0 to 127). In the Excelsheet I am using 1 to 128
  • NSJW[6:0]: Nominal (re)synchronization jump width (Valid values are 0 to 127.) In the Excelsheet I am using 1 to 128

data bit time parameter range

  • DBRP[4:0]: Data bit rate prescaler ( Valid values are 0 to 31). In the Excelsheet I am using 1 to 32
  • DTSEG1[4:0]: Data time segment before sample point (Valid values are 0 to 31). In the Excelsheet I am using 1 to 32
  • DTSEG2[3:0]: Data time segment after sample point (Valid values are 0 to 15.) In the Excelsheet I am using 1 to 16
  • DSJW[3:0]: Synchronization jump width (valid values are 0 to 15.) In the Excelsheet I am using 1 to 16

Attention because this calculation tool is for the ST HAL (FDCAN HAL module driver), the result value have to be set through the HAL_FDCAN_Init() function, and this is the reason why in my excel tool I am starting from 1 and not from 0 for the parameter values.
see some code excerpt from the HAL_FDCAN_Init() function:

` hfdcan->Instance->DBTP = ((((uint32_t)hfdcan->Init.DataSyncJumpWidth - 1U) << FDCAN_DBTP_DSJW_Pos) | \

                          (((uint32_t)hfdcan->Init.DataTimeSeg1 - 1U) << FDCAN_DBTP_DTSEG1_Pos)     | \

                          (((uint32_t)hfdcan->Init.DataTimeSeg2 - 1U) << FDCAN_DBTP_DTSEG2_Pos)     | \

                          (((uint32_t)hfdcan->Init.DataPrescaler - 1U) << FDCAN_DBTP_DBRP_Pos));

`

Clone this wiki locally