Skip to main content
Aero1972
Associate
May 5, 2020
Question

STM32G4xx FDCAN Delay Compensation

  • May 5, 2020
  • 3 replies
  • 1781 views

A little something I have noticed today. I have been developing an application which is using the G431 and uses FD-CAN. My code was working in External Loopback mode such that a CAN message of my choosing was being correctly received by an external device, yet in Normal mode otherwise the same code was creating error frames.

I had used the ST-provided HAL function HAL_FDCAN_ConfigTxDelayCompensation to ensure the self-reception of the message was compensated for the 4Mb/s bit rate I have chosen for the data part of the CAN frame.

The error frames were caused because there is a bit in the FDCAN_DBTP register which controls the delay compensation method which is not set by the ST-provided HAL function. This bit may be configurable elsewhere in the GUI or by other HAL functions, but it seems to me that a function designed to configure the delay compensation should include it where a non-zero time offet is desired.

For those who do not use the HAL, the DBTP register is part of the FDCAN_GlobalTypeDef struct - TDC is bit 23 of this register and must be set to true to enable delay compensation - see G431 Reference Manual Rev 2 page 1928.

My code now works so I can start to work on the Receive Message side.

I hope this helps somebody.

This topic has been closed for replies.

3 replies

BSpoe.1
Associate III
June 5, 2020

In the current firmware (for me it's STM32H7 FW V1.7.0) there should be a HAL function to enable this bit:

HAL_FDCAN_EnableTxDelayCompensation(&hfdcan);

ST Technical Moderator
June 18, 2020

Hello,

Could you please confirm that adding HAL function HAL_FDCAN_EnableTxDelayCompensation(&hfdcan); resolve your issue?

Otherwise, please details more your issue and share your source code ?

Best Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Aero1972
Aero1972Author
Associate
June 19, 2020

Dear Imen,

I am afraid in the 7 weeks since I posted, much of the HAL code has been removed.

I have made a separate project to test both the functions HAL_FDCAN_EnableTxDelayCompensation() and HAL_FDCAN_ConfigTxDelayCompensation() and that project works.

Kind Regards,