STM32 gotchas
241. RTC rolls over from 12:59:59 to 01:00:00, and does not flip the AM/PM flag

This is normal.

The rules of 12-hour time are relatively surprising, with the AM/PM rollover not matching the hour rollover 1:

While these rules are not STM32-specific, the STM32 RTC (in v2 and v3) follows them, flipping the AM/PM indicator (RTC_TR.PM) at noon and midnight, and rolling over from 12:59:59 to 01:00:00 one hour later.

This behaviour is quite confusing to users (usually from non-english-speaking countries), who are not accustomed to 12-hour time: user sets RTC time to 12:xx:xx and then observes it to roll over to 01:00:00 without flipping the AM/PM flag. The confusion is even higher if the user did not set the 12-hour mode (RTC_CR.FMT=1). This can happen due to the relatively common problem with calling Cube/HAL functions with uninitialized init structs.


1. There are also alternative, and even more confusing rules for the rollovers in 12-hour time.