GD32A50x User Manual
318
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:
1.
Wait until the value of LWOFF bit in the RTC_CTL register sets to '1';
2.
Enter Configuration mode by setting the CMF bit in the RTC_CTL register;
3.
Write to the RTC registers;
4.
Exit Configuration mode by clearing the CMF bit in the RTC_CTL register;
5.
Wait until the value of LWOFF bit in the RTC_CTL register sets to '1'.
17.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 17-2.
RTC second and alarm waveform example (RTC_PSC = 3, RTC_ALRM = 2)
RTC_ Alarm
0
1
2
3
4
RTC_Second
RTC_ CNT
ALRMIF
RTC_ PSC
ALRMIF flag can be cleared by software
RTCCLK
2
3
1
0
3
1
1
3
3
2
1
0
2
0
2
0
2
1