![GigaDevice Semiconductor GD32E23 Series User Manual Download Page 201](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794201.webp)
GD32E23x User Manual
201
-
reference clock input: RTC_REFIN(50 or 60 Hz)
13.3.2.
Clock source and prescalers
RTC unit has three independent clock sources: LXTAL, IRC40K and HXTAL divided by 32.
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
(13-1)
𝑓
ck_spre
=
𝑓
ck_apre
FA 1
=
𝑓
rtcclk
(FA 1)*(FA 1)
(13-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.
13.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 (
𝑓
apb
) must be at least 7 times the frequency of
the RTC clock (
𝑓
rtcclk
).
System reset will reset the shadow calendar registers.
13.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(x=0)bit in RTC_CTL. If all the
alarm fields value match the corresponding calendar value when ALRMxEN=1(x=0), 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(x=0).