2024-02-27 02:45 AM - edited 2024-02-29 03:13 AM
Hello
We have recently run into a problem after porting code from the G474 to the F334 where the call to HAL_HRTIM_WaveformTimerConfig() inside MX_HRTIM1_Init() would run into the Error_Handler() on every start, unless the code was compiled without any optimization (i.e. -O0) in which case it would work under some conditions but not under others.
Looking at the code generated for the F334 we noticed that the calibration is performed using the HAL_HRTIM_DLLCalibrationStart_IT() function which seems very wrong to us as it doesn't wait for the calibration to actually complete before continuing with the configuration. Comparing this to the code generated for the G474 we see that there the code calls HAL_HRTIM_DLLCalibrationStart() followed by HAL_HRTIM_PollForDLLCalibration() which is what we would expect.
So apparently, without optimizations, the F334 code runs slowly enough for the calibration to complete, at least in some cases, before other configuration takes place, but not so with optimizations enabled (such as -Og or -O1).
Manually changing the F334 code to match the G474 code fixes the issue for us, but of course this would mean having to remember to correct the code every time we regenerate it from CubeMX/CubeIDE.
Can anybody (preferably from ST) confirm that this is indeed a bug in CubeMX or is there something else we are missing here?
Thanks in advance.
2024-07-08 06:43 AM
This turned out to be our own mistake. We had erroneously selected "DLL Calibration with IT Generation" instead of "Simple DLL Calibration".
I still wonder, though, whether this would ever actually work in cases where IT Generation is required...