Closed 0x0fe closed 2 weeks ago
Hi @0x0fe This issue is not related STM32 core as it is purely HAL usage. You should report to the HAL repository. About the clock config, it is described in the Wiki: https://github.com/stm32duino/Arduino_Core_STM32/wiki/Custom-definitions#systemclock_config
So, while testing the CANFD interfaces of STM32G0B1CB and CC on this core i found a rather strange bug, i am not sure what cause this : When initializing the CANFD interfaces, 2 interfaces in the case of this variant, for some reason the HAL_FDCAN_MspInit function is only called for the first instance, but it should be called for each instance, otherwise the GPIOs are not initialized correctly (at the very least), the second instance won't work at all.
Below is my test code, which simply set the two CANFD ports up for a local test, port 1 to port 2 and port2 to port1 etc. As you can see, in HAL_FDCAN_MspInit i had to disable the condition on the CANFD2 init so that it is executed at the first call (when CANFD1 is initialized) because HAL_FDCAN_MspInit will never be called again when CANFD2 is initialized, despite HAL_FDCAN_Start(phfdcan2) is correctly called in my code.
As a side note, could you please clarify what is the best practice to override the default clock init from the sketch because i noticed the default clock init from variants sets the system clock to 48M from the HSI, not optimal when we have an HSE and want to run at max speed (64M for the G0B1). Thanks.