GD32W51x User Manual
402
The registers protected by INITPRIP are write-protected by the INIT KEY.
The registers protected by CALDPRIV are write-protected by the CAL KEY.
In case RTCPRIP or INITPRIP is set in the RTC_PPM_CTL, and/or DPROT or INITSECP is
cleared in the RTC_SPM_CTL: the INIT KEY is unlocked and locked only if the write accesses
into the RTC_ WPK register are done in the privilege and security mode defined by RTCPRIP,
INITPRIP, DPROT, INITSECP configuration.
In case RTCPRIP or CALCPRIP is set in the RTC_PPM_CTL, and/or DPROT or CALSECP
is cleared in the RTC_SPM_CTL: the CAL KEY is unlocked and locked only if t he write
accesses into the RTC_WPK register are done in the privilege and security mode defined by
RTCPRIP, CALCPRIP, DPROT, CALSECP configuration.
Calendar initialization and configuration
The prescaler and calendar value can be programmed by the following steps:
1.
Enter initialization mode (by setting INITM=1) and polling INITF bit until INITF=1.
2.
Program both the asynchronous and synchronous prescaler factors in RTC_PSC register.
3.
Write the initial calendar values into the shadow calendar registers (RTC_TIME and
RTC_DATE), and use the CS bit in the RTC_CTL register to configure the time format
(12 or 24 hours).
4.
Exit the initialization mode (by setting INITM=0).
About 4 RTC clock cycles later, real calendar registers will load from shadow registers and
calendar counter restarts.
Note:
Reading calendar register (BPSHAD=0) after initialization, software should confirm the
RSYNF bit to 1.
YCM flag indicates whether the calendar has been initialized by checking the year field of
calendar.
Daylight saving Time
RTC unit supports daylight saving time adjustment through S1H, A1H and DSM bit.
S1H and A1H can subtract or add 1 hour to the calendar when the calendar is running.S1H
and A1H operation can be tautologically set and DSM bit can be used to recording this adjust
operation. After setting the S1H/A1H, subtract/add 1 hour will perform when next sec ond
comes.
Alarm function operation process
To avoid unexpected alarm assertion and metastable state, alarm function has an operation
flow:
1.
Disable Alarm (by resetting ALRMxEN in RTC_CTL)