
GD32L23x User Manual
263
the same, the data is coherent and correct.
16.3.8.
Resetting the RTC
There are two reset sources used in RTC unit: system reset and backup domain reset.
System reset will affect calendar shadow registers and some bits of the RTC_STAT. When
system reset is valid, the bits or registers mentioned before are reset to the default value.
Backup domain reset will affect the following registers and system reset will not affect them:
-
RTC current real-time calendar registers
-
RTC Control register (RTC_CTL)
-
RTC Prescaler register (RTC_PSC)
-
RTC Wakeup timer register (RTC_WUT)
-
RTC High resolution frequency compensation register (RTC_HRFC)
-
RTC Shift control register (RTC_SHIFTCTL)
-
RTC Time stamp registers (RTC_SSTS/RTC_TTS/RTC_DTS)
-
RTC Tamper register (RTC_TAMP)
-
RTC Backup registers (RTC_BKPx)
-
RTC Alarm registers (RTC_ALRMxSS/RTC_ALRMxTD(x=0,1))
The RTC unit will go on running when system reset occurs or enter power saving mode, but
if backup domain reset occurs, RTC will stop counting and all registers will reset.
16.3.9.
RTC shift function
When there is a remote clock with higher degree of precision and RTC 1Hz clock (ck_spre)
has an offset (in a fraction of a second) with the remote clock, RTC unit provides a function
named shift function to remove this offset and thus make second precision higher.
RTC_SS register indicates the fraction of a second in binary format and is down counting
when RTC is running. Therefore by adding the SFS[14:0] value to the synchronous prescaler
counter SSC[15:0] or by adding the SFS[14:0] value to the synchronous prescaler counter
SSC[15:0] and at the same time set A1S bit can delay or advance the time when next second
arrives.
The maximal RTC_SS value depends on the FACTOR_S value in RTC_PSC. The higher
FACTOR_S, the higher adjust precision.
Because of the 1Hz clock (ck_spre) is generated by FACTOR_A and FACTOR_S, the higher
FACTOR_S means the lower FACTOR_A, then more power consuming.
Note:
Before using shift function, the software must check the MSB of SSC in RTC_SS
(SSC[15]) and confirm it is 0.
After writing RTC_SHIFTCTL register, the SOPF bit in RTC_STAT will be set at once. When
shift operation is complete, SOPF bit is cleared by hardware. System reset does not affect
SOPF bit.
Shift operation only works correctly when REFEN=0.
Software must not write to RTC_SHIFTCTL if REFEN=1.