I have a strange issue with the RTC of an STM32 F407 in one of my projects.
Abstract: The function HAL_RTC_GetTime(...) updates the output value only once, then remains at the same valule, but it updates if I set a breakpoint in this function.
Description: I have recently updated from CubeIDE 1.8.0 to CubeIDE 1.9.0. At one of my projects I have these strange issues, described above. Before the update of the IDE all worked fine. After the Update these strange issues occur. This might be a coincidence, but 2 days ago all worked fine.
What have I done to resolve this issue: first of all, I set some breakpoints along the call chain and finally in the HAL function, where the return value is generated. I found out this way, that the members of the RTC_TimeTypeDef struct are updated correctly if the debugger stops the execution of the programm, but is NOT updated, when the brakpoint is removed.
My first guess was: ok, something went wrong with the drivers during the Update to CubeMX 6.5 / CubeIDE 1.9.0
Attempt 1: I removed the RTC from the Project Setup, compliled the Project (was OK), added the RTC to the Project again, with the same behaviour.
Attempt 2: I created a backup of all my code, deleted the project, created it new, restored my code and tried again. With the same result (mind = blown) I did not expect this, because - at least now - all files generated by CubeMX had to be generated new from scratch with the latest drivers.
In the debugger window I can see that the members Hours, Minutes, Seconds of the Struct "RTC_TimeTypeDef" do not change at all, instead DayLightSaving and StoreOperation are changing randomly, while SubSeconds seem to count correctly.
Furthermore: The RTC Timer itself seems to work correctly as hrtc->Instance->TR seems to count the seconds
For me it looks like some bitmasks or whatever are messed up and instead of shifting the Hours, Minutes and Seconds into the members of the Structm, HAL_RTC_GetTime(...) shifts these values into DayLightSaving and StoreOperation.
Has anyone an idea, what's going on here? Especially why it works when a breakpoint is set, but otherwise not? Any hint, how I could track this down is appreciated.
My workaround will most probably be, that I use the value from hrtc->Instance->TR directly and write my own conversion. But I'd really like to understand whats going wrong here.
Thank you and best regards, Chris