GD32F20x User Manual
318
17.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 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 which is 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
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...