Skip to main content
Graduate II
June 18, 2025
Question

STM32 classic can bit rate config

  • June 18, 2025
  • 1 reply
  • 515 views

Hi,
I'm currently working on the STM32G491 board and implementing CAN communication.

With the system clock configured using PLL at 80 MHz, I have set up the CAN peripheral with the following parameters:

 
 hfdcan1.Init.NominalPrescaler = 10;
 hfdcan1.Init.NominalSyncJumpWidth = 2;
 hfdcan1.Init.NominalTimeSeg1 = 13;
 hfdcan1.Init.NominalTimeSeg2 = 2;
 hfdcan1.Init.DataPrescaler = 2;
 hfdcan1.Init.DataSyncJumpWidth = 2;
 hfdcan1.Init.DataTimeSeg1 = 13;
 hfdcan1.Init.DataTimeSeg2 = 2;
 hfdcan1.Init.StdFiltersNbr = 10;
 hfdcan1.Init.ExtFiltersNbr = 0;

With this configuration:

  • The nominal time quantum (TQ) is 125 ns

  • Nominal bit time is 2000 ns

  • Bitrate is 500 kbps

This setup works as expected.

Now, I need to run the same CAN configuration using the internal HSI clock at 16 MHz. I updated the CAN settings accordingly:

 

hfdcan1.Init.NominalPrescaler = 2;
hfdcan1.Init.NominalSyncJumpWidth = 2;
hfdcan1.Init.NominalTimeSeg1 = 13;
hfdcan1.Init.NominalTimeSeg2 = 2;
hfdcan1.Init.DataPrescaler = 2;
hfdcan1.Init.DataSyncJumpWidth = 2;
hfdcan1.Init.DataTimeSeg1 = 13;
hfdcan1.Init.DataTimeSeg2 = 2;

hfdcan1.Init.StdFiltersNbr = 10;
hfdcan1.Init.ExtFiltersNbr = 0;

This also results in:

  • Nominal time quantum of 125 ns

  • Bit time of 2000 ns

  • Bitrate of 500 kbps

However, communication is not happening with this 16 MHz configuration.
Is a higher system clock (like 80 MHz) required for CAN to function reliably, or can 16 MHz be used with the right settings?

 

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    June 18, 2025

    Hello,

    What do you mean by "However, communication is not happening with this 16 MHz configuration." You mean the transmission? 

    Did you try the External loopback mode and probe what happens on CAN_Tx?

    Knowing that HSI is not recommended for CAN communication in Normal mode.

    What board are you using? also better to share your ioc file.

    Graduate II
    June 18, 2025

    Hi @mƎALLEm ,
    I am using PCAN view in PC and transmitting CAN messages to my MCU. in 80 MHZ config the transmission happens on both side. but in 16 mhz I am not getting any data on both side.

    Technical Moderator
    June 18, 2025

    Before going ahead with Normal mode please try with the External Loopback mode at least to discard any hardware effects.