2025-07-15 10:23 AM - last edited on 2025-07-15 10:50 AM by mƎALLEm
Hi, I made an STM32G4 and TCAN1044VDRQ1 setup and tried to use the FDCAN, but I couldn't get it to work. There is no response from the transceiver. I tried all the bit timings and used calculators to compute the values. I used a USB-to-CAN FD analyzer and sent a message, but there is no response in the HAL_FDCAN_RxFifo0Callback interrupt.
It is not getting triggered when a message comes in. I don’t know what to do. I’ve spent too much time on this. Any help would be appreciated. Thank you. I don’t know what other details I need to share, if you think you need something, please let me know and I’ll send a reply.
void CAN_Init(uint8_t can_id) {
hfdcan1.Instance = FDCAN1;
hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1;
hfdcan1.Init.FrameFormat = FDCAN_FRAME_FD_NO_BRS;
hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan1.Init.AutoRetransmission = ENABLE;
hfdcan1.Init.TransmitPause = DISABLE;
hfdcan1.Init.ProtocolException = DISABLE;
hfdcan1.Init.NominalPrescaler = 1;
hfdcan1.Init.NominalSyncJumpWidth = 3;
hfdcan1.Init.NominalTimeSeg1 = 8;
hfdcan1.Init.NominalTimeSeg2 = 3;
hfdcan1.Init.DataPrescaler = 1;
hfdcan1.Init.DataSyncJumpWidth = 3;
hfdcan1.Init.DataTimeSeg1 = 8;
hfdcan1.Init.DataTimeSeg2 = 3;
hfdcan1.Init.StdFiltersNbr = 1;
hfdcan1.Init.ExtFiltersNbr = 0;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) Error_Handler();
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = can_id;
sFilterConfig.FilterID2 = 0x7FF;
if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK) Error_Handler();
if (HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE) != HAL_OK) Error_Handler();
if (HAL_FDCAN_Start(&hfdcan1) != HAL_OK) Error_Handler();
}
2025-07-15 10:49 AM - edited 2025-07-15 10:53 AM
Hello,
Please no internal clock with CAN communication in Normal mode (HSI, CSI etc ..): CAN2.0/CANFD. That's not recommanded at all. You can use the internal clock only in Loopback mode.
Please use HSE with an external accurate clock source example a crystal (100ppm is sufficient).
Please refer to these articles:
STM32 FDCAN running at 8 Mb/s on NUCLEO boards
How to use STLINK-V3 MCO output on Nucleo boards as a precise clock source for STM32
2025-07-15 11:02 AM
Still i tried in Loopback mode. that didn't work either.
2025-07-15 12:31 PM - edited 2025-07-15 12:36 PM
For Normal mode use the provided example in the github: https://github.com/stm32-hotspot/CKB-STM32-FDCAN-8Mbs / Article: STM32 FDCAN running at 8 Mb/s on NUCLEO boards
Especially for G4: https://github.com/stm32-hotspot/CKB-STM32-FDCAN-8Mbs/tree/main/NUCLEO-G474
For Loopback mode: https://github.com/STMicroelectronics/STM32CubeG4/tree/master/Projects/STM32G474E-EVAL/Examples/FDCAN/FDCAN_Loopback
2025-07-15 1:25 PM
upload your IOC file.
2025-07-15 8:40 PM - edited 2025-07-15 8:58 PM
@Karl Yamashita Thank you for replying. I have attached my IOC below. The only thing my working on is CANFD so only that is configured in the IOC I'm using the default PA11 and PA12 pins
2025-07-15 8:41 PM
will it work if i use the same bit timings for my transceiver too ?
2025-07-16 12:53 AM - edited 2025-07-16 1:05 AM
Hello,
1- What is the mode you plan to use: Classic or FD?
2- Target bitrate? if FDCAN provide both Nominal and data phase bitrates
3- Better to attach your complete project. If not possible in public send it in private.
Please answer the three questions above.
2025-07-16 1:30 AM
Hi
1- I'm going to use CANFD
2- FDCAN (I'm not sure of the bitrate but i think 1Mbs is sufficient for my needs ) - i just need communication
3- I'll share my GitHub repo That would be better if somebody needs it they can use it.
STM32G431CANFD
Also i saw your post on FDCAN bit time configuration but it doesn't tell how to get the values of
2025-07-16 1:44 AM - edited 2025-07-16 1:49 AM
@kavinkumar wrote:
2- FDCAN (I'm not sure of the bitrate but i think 1Mbs is sufficient for my needs ) - i just need communication
Not sure? how? you need to know and decide what bitrates you need to use for both Nominal and Data phases.
For FDCAN bit time please use Kvaser CANFD bit time tool.