cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0B1 fdcan can't recieve messeages.

Haru
Associate II

I am currently implementing communication between STM32G0B1 and STM32H743 using FDCAN.

However, I am unable to receive stably. Sometimes it works, sometimes not.

Specifically, the following is happening.

(G0B1 Recieve)

・Data is actually in Fifo, but no receive interrupt occurs sometimes.

・Probability of occurrence of no interrupt is around 60%.

The settings are as follows.

(Setting)

・Transmission speed 100khz.

・Transmission mode is classic CAN.

・Filter is set to receive all data.

(Program) ※Created using CubeMx(6.5.0).

・G0B1

hfdcan1.Instance = FDCAN1;

hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;

hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;

hfdcan1.Init.AutoRetransmission = ENABLE;

hfdcan1.Init.TransmitPause = DISABLE;

hfdcan1.Init.ProtocolException = ENABLE;

hfdcan1.Init.NominalPrescaler = 20;

hfdcan1.Init.NominalSyncJumpWidth = 1;

hfdcan1.Init.NominalTimeSeg1 = 22;

hfdcan1.Init.NominalTimeSeg2 = 2;

hfdcan1.Init.DataPrescaler = 1;

hfdcan1.Init.DataSyncJumpWidth = 1;

hfdcan1.Init.DataTimeSeg1 = 1;

hfdcan1.Init.DataTimeSeg2 = 1;

hfdcan1.Init.StdFiltersNbr = 1;

hfdcan1.Init.ExtFiltersNbr = 0;

hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;

・H743

hfdcan2.Instance = FDCAN2;

hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC;

hfdcan2.Init.Mode = FDCAN_MODE_NORMAL;

hfdcan2.Init.AutoRetransmission = ENABLE;

hfdcan2.Init.TransmitPause = DISABLE;

hfdcan2.Init.ProtocolException = ENABLE;

hfdcan2.Init.NominalPrescaler = 20;

hfdcan2.Init.NominalSyncJumpWidth = 1;

hfdcan2.Init.NominalTimeSeg1 = 22;

hfdcan2.Init.NominalTimeSeg2 = 2;

hfdcan1.Init.DataPrescaler = 1;

hfdcan1.Init.DataSyncJumpWidth = 1;

hfdcan1.Init.DataTimeSeg1 = 1;

hfdcan1.Init.DataTimeSeg2 = 1;

hfdcan2.Init.MessageRAMOffset = 0;

hfdcan2.Init.StdFiltersNbr = 1;

hfdcan2.Init.ExtFiltersNbr = 0;

hfdcan2.Init.RxFifo0ElmtsNbr = 64; 

hfdcan2.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;

hfdcan2.Init.RxFifo1ElmtsNbr = 0; 

hfdcan2.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;

hfdcan2.Init.TxFifoQueueElmtsNbr = 1;

hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;

hfdcan2.Init.TxElmtSize = FDCAN_DATA_BYTES_8;

・Interrupt

HAL_FDCAN_ConfigGlobalFilter(&hfdcan2, FDCAN_REJECT,FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);

HAL_FDCAN_RegisterRxFifo0Callback(&hfdcan2, _RxFifo0Callback);

HAL_FDCAN_RegisterCallback(&hfdcan2, HAL_FDCAN_ERROR_CALLBACK_CB_ID, svErrorCallback);

HAL_FDCAN_RegisterCallback(&hfdcan2, HAL_FDCAN_TX_FIFO_EMPTY_CB_ID, svTxFifoEmptyCallback);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_TX_FIFO_EMPTY, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_RAM_ACCESS_FAILURE, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_ERROR_LOGGING_OVERFLOW, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_RAM_WATCHDOG, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_ARB_PROTOCOL_ERROR, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_DATA_PROTOCOL_ERROR, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_RESERVED_ADDRESS_ACCESS, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_ERROR_PASSIVE, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_ERROR_WARNING, 0);

HAL_FDCAN_ActivateNotification(&hfdcan2, FDCAN_IT_BUS_OFF, 0);

Best regards.

3 REPLIES 3
SofLit
ST Employee

Hello,

  • If you are using HSI as source clock, use an external crystal instead.
  • Check your HW and wiring continuity: transceivers power stability + 2 termination resistor of 120 ohms your wires etc ..
  • Check your bitrate computation for both sides H7 and G0. They should have the exact bitrate.
To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@Community member​ 

Thanks for the advice.

The H7 and G0 are clocked at 50 MHz and have the same parameters, so the bit rate should not be a problem.So I will try to HSE as source clock.

akuma.51
Associate II

@Haru​  did ur problem solve after using HSE as source clock.