cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4xx FDCAN Delay Compensation

Aero1972
Associate

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.

3 REPLIES 3
BSpoe.1
Associate III

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);

Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Aero1972
Associate

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,