GD32W51x User Manual
400
16.3.2.
Clock source and prescalers
RTC unit has three independent clock sources: LXTAL, IRC32K and HXTAL with divided by
2~31(configured in RCU_CFG register).
In the RTC unit, there are two prescalers used for implementing the calendar and other
functions. One prescaler is a 7-bit asynchronous prescaler and the other is a 15-bit
synchronous prescaler. Asynchronous prescaler is mainly used for reducing power
consumption. The asynchronous prescaler is recommended to set as high as possible if both
prescalers are used.
The frequency formula of two prescalers is shown as below:
𝑓
ck_apre
=
𝑓
rtcclk
FA 1
(17-1)
𝑓
ck_spre
=
𝑓
ck_apre
FA 1
=
𝑓
rtcclk
(FA 1)*(FA 1)
(17-2)
The ck_apre clock is used to driven the RTC_SS down counter which stands for the time left
to next second in binary format and when it reaches 0 it will automatically reload FACTOR_S
value. The ck_spre clock is used to driven the calendar registers. Each clock will make second
plus one.
16.3.3.
Shadow registers introduction
BPSHAD control bit decides the location when APB bus accesses the RTC calendar register
RTC_DATE, RTC_TIME and RTC_SS. By default, the BPSHAD is cleared, and APB bus
accesses the shadow calendar registers. Shadow calendar registers is updated with the value
of real calendar registers every two RTC clock and at the same time RSYNF bit will be set
once. This update mechanism is not performed in Deep-Sleep mode and Standby mode.
When exiting these modes, software must clear RSYNF bit and wait it is asserted (the max
wait time is 2 RTC clock) before reading calendar register under BPSHAD=0 situation.
Note
: When reading calendar registers (RTC_SS, RTC_TIME, RTC_DATE) under
BPSHAD=0, the frequency of the APB clock (fapb) must be at least 7 times the frequency of
the RTC clock (frtcclk).
System reset will reset the shadow calendar registers.
16.3.4.
Configurable and field maskable alarm
RTC alarm function is divided into some fields and each has a maskable bit.
RTC alarm function can be enabled or disabled by ALRMxEN bit in RTC_CTL. If all the alarm
fields value match the corresponding calendar value when ALRMxEN=1, the Alarm flag will
be set.
Note:
FACTOR_S in the RTC_PSC register must be larger than 3 if MSKS bit reset in
RTC_ALRMxTD.