2025-01-13 06:11 AM
Hello,
I use CubeMX V6.13.0 (now the newest version).
I have find out a bug in the configuration wizzard from the FDCAN with the STM32G473.
When I chose:
FDCAN1, Clock Divider = "Divide kernel clock by 10"
FDCAN2, Clock Divider = "Divide kernel clock by 1"
Then start the FDCAN1 and start the FDCAN2, then the FDCAN2 works not with the correct bitrate.
The problem is: CubeMX does not know the µC has only one "Clock Divider".
See RM0440, Rev 8, at 44.4.37 (page 2011):
"Note: The clock divider is common to all FDCAN instances. Only FDCAN1 instance has
FDCAN_CKDIV register, which changes clock divider for all instances."
If I choice for FDCAN1 a other Clock Divider as by 1, the the bitrate calculation for FDCAN2 and FDCAN3 is bad.
Please fix this bug in CubeMx,
Thanks a lot.
Best Regads Markus
2025-01-13 06:51 AM
Hello,
Do you mean the issue is in the CubeMx GUI so the bitrate value is wrongly shown in FDCAN2/FDCAN3 parameters?
2025-01-13 07:26 AM
Yes, but there are 2 issue:
1) I choice in FDCAN1 the Clock Divider as "Divide kernel clock by 10", in this case the parameter "Clock Divider" has automatically change from the FDCAN2 and FDCAN3 to "Clock Divider" to "Divide kernel clock by 10". Currently, the FDCAN2/3 is showing all time "Divide kernel clock by 1"
2) Choice FDCAN1 Clock Divider as "Divide kernel clock by 10", then the bit rate from FDCAN2/3 is wrongly calculated.
3) CubeMX design:
But I think it is better to add a in the left side into "Connectivity" a exta "FDCAN general" section to choice this Clock Divider, that is used for all FDCAN1/2/3 instances.
4) Code generation:
Now the code generation build this code:
static void MX_FDCAN1_Init(void)
{
hfdcan1.Instance = FDCAN1;
hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV10;
: : :
static void MX_FDCAN2_Init(void)
{
hfdcan2.Instance = FDCAN2;
hfdcan2.Init.ClockDivider = FDCAN_CLOCK_DIV1;
: : :
HAL_FDCAN_SetClockDivider(FDCAN_CLOCK_DIV10);
that is also confusing. This looks as if each individual FDCAN has its own ClockDivider.
It is better to delete the "...Init.ClockDivider" and add into the HAL a funktion named like:
HAL_FDCAN_SetClockDivider(FDCAN_CLOCK_DIV10);
2025-01-13 07:28 AM
The format in my last post in the source is not so good, the editor do not that what I wnt have.
Best regads. Markus
2025-01-13 07:30 AM
Issue escalated internally. Ticket number 200299 (not accessible by community members).
2025-01-13 08:09 AM
Solution removed until a final answer is provided.