I use:
- STM32L071K8U3
- Segger JLink + Segger Ozone + SWD with 4 MHz
- Cube Ide
- External LSE or internal LSE, same problem.
I wrote firmware that displays the time using the RTC. To update the display, I check if the time has changed, like this:
if (hrtc.Instance->TR != trBefore) {
trBefore = hrtc.Instance->TR;
...
}
Or like this (more portable):
if (HAL_RTC_GetTime(&hrtc, &rtcTime, RTC_FORMAT_BCD) != HAL_OK) {
Error_Handler();
}
if (rtcTime.Seconds != secondsBefore) {
secondsBefore = rtcTime.Seconds;
...
}
Everything works fine, except that the time is not changing.
Using the debugger, I found that the RTC registers don't change.
If I use breakpoints and step into this HAL_RTC_GetTime
and observe the RTC registers,
then they change, and as a consequence, my clock display is updated with the new time value.
Maybe related to this: if I use Cube Ide Eclipse CDT debugger instead of Segger Ozone, I sometimes get an error message "interrupt failed". I suspect this is related; something weird is going on here.
Also, if I completely disconnect the debugger, and flash the firmware with JFlash, everything works properly, except the time is not advancing on my display.