STM32G474, [FD]CAN, Random duplicate frames on CAN bus, why?
Great ST Community,
Problem:
Why do I have random duplicate frames on the CAN bus with a STM32G474?
Context:
I am using STM32G474 ;
I am using FDCAN1 (can not try with FDCAN2) with Classical CAN frames ;
STM32Cube FW_G4 V1.4.0 ;
STM32CubeIDE 1.7.0 ;
I used these tools to configure bit times:
I want 500 kBauds, from 24 MHz, so my configuration is:
- hfdcan1.Instance = FDCAN1;
- hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1;
- hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_BRS;
- hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
- hfdcan1.Init.AutoRetransmission = ENABLE;
- hfdcan1.Init.TransmitPause = ENABLE;
- hfdcan1.Init.ProtocolException = DISABLE;
- hfdcan1.Init.NominalPrescaler = 3;
- hfdcan1.Init.NominalSyncJumpWidth = 2;
- hfdcan1.Init.NominalTimeSeg1 = 13;
- hfdcan1.Init.NominalTimeSeg2 = 2;
- hfdcan1.Init.DataPrescaler = 3;
- hfdcan1.Init.DataSyncJumpWidth = 2;
- hfdcan1.Init.DataTimeSeg1 = 13;
- hfdcan1.Init.DataTimeSeg2 = 2;
- hfdcan1.Init.StdFiltersNbr = 0;
- hfdcan1.Init.ExtFiltersNbr = 0;
- hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
I am using a TxHeader with theses parameters:
- TxHeader1.Identifier = 220;
- TxHeader1.IdType = FDCAN_STANDARD_ID;
- TxHeader1.TxFrameType = FDCAN_DATA_FRAME;
- TxHeader1.DataLength = FDCAN_DLC_BYTES_8;
- TxHeader1.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
- TxHeader1.BitRateSwitch = FDCAN_BRS_OFF;
- TxHeader1.FDFormat = FDCAN_CLASSIC_CAN;
- TxHeader1.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
- TxHeader1.MessageMarker = 0;
I tried to dialog with another STM32G474 (same boards) => Problem, from both MCUs.
with a STM32F7 (so necessary CAN only and not FDCAN) => same results by STM32G4 only.
I have stub CAN bus with a charge 120 Ohms, with only 2 nodes.
I see the random duplicate frames with a logical analyzer and with an oscilloscope.
Tx signals (MCU side) are cleaned. Bus signal is cleaned too.
Example with a duplicate frame five times:
Captured with Ikalogic SP209i and find attached data. You can analyze them with ScanStudio free software tool.
After, the receiver sends another message in reaction. So the message is really received once...
Do you have an idea?
Thanks in advance!
Working ressources:
- User manuel reference for STM32G4 ;
- User manuel reference for HAL/LL STM32G4 ;
- 3 application notes for FDCAN (bootloader, etc) ;
- https://www.youtube.com/watch?v=yQsiHH5R3ZM and its PDF support document;
- STM32CubeIDE, examples for STM32G4 named "FDCAN_Classic_Frame_Networking";
