22.5.6.1 Gregorian and Persian Modes
To update time and date, the RTC must be stopped by setting the corresponding field in the Control register (RTC_CR). The RTC_CR.UPDTIM bit must be set to update time fields (hour, minute, second) and RTC_CR.UPDCAL must be set to update calendar fields (century, year, month, date, day). When both time and calendar fields require an update, RTC_CR.UPDTIM and RTC_CR.UPDCAL must be written to 1 in the same access.
RTC_SR.ACKUPD must then be read to 1 by either polling the RTC_SR or by enabling the acknowledge update interrupt by writing a 1 in RTC_IER.ACKEN. Once RTC_SR.ACKUPD is read to 1, it is mandatory to clear this flag by writing a 1 in RTC_SCCR.ACKCLR, after which the user can write to RTC_TIMR, RTC_CALR, or both.
Once the update is finished, the user must write a 0 in the bits RTC_CR.UPDTIM and RTC_CR.UPDCAL.
The timing sequence of the time/calendar update is described in Figure 22-2.
When entering the Programming mode of the calendar fields, the time fields remain enabled. When entering the Programming mode of the time fields, both the time and the calendar fields are stopped. This is due to the location of the calendar logical circuity (downstream for low-power considerations).
In successive update operations, the user must first check that RTC_CR.UPDTIM and RTC_CR.UPDCAL read 0 before writing a 1 in these bits.
