GD32VF103 User Manual
215
14.3.3.
RTC configuration
The RTC_PSC, RTC_CNT and RTC_ALRM registers in the RTC core are writable. These
registers
’
value can be set only when the peripheral enter configuration mode. And the CMF
bit in the RTC_CTL register is used to indicate the configuration mode status. The write
operation executes when the peripheral exit configuration mode, and it takes at least three
RTCCLK cycles to complete. The value of the LWOFF bit in the RTC_CTL register sets to
‘
1
’
,
if the write operation finished. The new write operation should wait for the previous one
finished.
The configuration steps are as follows:
a) Wait until the value of LWOFF bit in the RTC_CTL
register sets to ‘1’;
b) Enter Configuration mode by setting the CMF bit in the RTC_CTL register;
c) Write to the RTC registers;
d) Exit Configuration mode by clearing the CMF bit in the RTC_CTL register;
e) Wait until the value of LWOFF bit in the RTC_CTL register set
s to ‘1’.
14.3.4.
RTC flag assertion
Before the update of the RTC Counter, the RTC second interrupt flag (SCIF) is asserted on
the last RTCCLK cycle.
Before the counter equal to the RTC Alarm value which stored in the Alarm register increases
by one, the RTC Alarm interrupt flag (ALRMIF) is asserted on the last RTCCLK cycle.
Before the counter equals to 0x0, the RTC Overflow interrupt flag (OVIF) is asserted on the
last RTCCLK cycle.
The RTC Alarm write operation and Second interrupt flag must be synchronized by using
either of the following sequences:
Use the RTC alarm interrupt and update the RTC Alarm and/or RTC Counter registers
inside the RTC interrupt routine;
Update the RTC Alarm and/or the RTC Counter registers after the SCIF bit to be set in
the RTC Control register.
Figure 14.2. RTC second and alarm waveform example (RTC_PSC = 3, RTC_ALRM =