GD32A50x User Manual
317
(stored in the RTC_ALRMH/L register).
Figure 17-1. Block diagram of RTC
RTC_DIV
RTC_PSC
RTC_CNT
RTC_ALRM
COMPARE
APB interface
SCIF
SCIE
OVIF
OVIE
ALRMIF
ALRMIE
NVIC
interrupt
controler
APB1 BUS
RTCCLK
Reload
SC_CLK
RTC_Second
RTC_Overflow
RTC_Alarm
Ri sing edge
EXIT STANDBY MODE
EXTI LINE 17
HXTAL
/
128
LXTAL
IRC40K
RTCSRC[1:0]
BACKUP DOMAIN
PCLK1
RTC Interrupt
17.3.1.
RTC reset
The APB interface and the RTC_INTEN register are reset by system reset. The RTC core
(prescaler, divider, counter and alarm) is reset only by a backup domain reset.
Steps to enable access to the backup registers and the RTC after reset are as follows:
1.
Set the PMUEN and BKPEN bits in the RCU_APB1EN register to enable the power and
backup interface clocks.
2.
Enable access to the backup registers and RTC by setting the BKPWEN bit in the
(PMU_CTL).
17.3.2.
RTC reading
The APB interface and RTC core are located in two different power supply domains.
In the RTC core, only counter and divider registers are readable registers. And the values in
the two registers and the RTC flags are internally updated at each rising edge of the RTC
clock, which is resynchronized by the APB1 clock.
When the APB interface is immediately enabled from a disable state, the read operation is
not recommended because the first internal update of the registers has not finished. That
means, when a system reset, power reset, waking up from Standby mode or Deep-sleep
mode occurs, the APB interface was in disabled state, but the RTC core has been kept
running. In these cases, the correct read operation should first clear the RSYNF bit in the
RTC_CTL register and wait for it to be set by hardware. While WFI and WFE have no effects
on the RTC APB interface.
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