GD32W51x User Manual
405
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.
16.3.10.
RTC reference clock detection
RTC reference clock detection is another way to increase the precision of RTC second. To
enable this function, you should have an external clock source (50Hz or 60 Hz) which is more
precise than LXTAL clock source.
After enabling this function (REFEN=1), each 1Hz clock (ck_spre) edge is compared to the
nearest RTC_REFIN clock edge. In most cases, the two clock edges are aligned every time.
But when two clock edges are misaligned for the reason of LXTAL poor precision, the RTC
reference clock detection function will shift the 1Hz clock edge a little to make next 1Hz clock
edge aligned to reference clock edge.
When REFEN=1, a time window is applied at every second update time different detection
state will use different window period.
7 ck_apre window is used when detecting the first reference clock edge and 3 ck_apre window
is used for the edge aligned operation.
Whatever window used, the asynchronous prescaler counter will be forced to reload when
the reference clock is detected in the window. When the two clock (ck_spre and reference
clock) edges are aligned, this reload operation has no effect for 1Hz clock. But when the two
clock edge are not aligned, this reload operation will shift ck_spre clock edge a bit to make
the ck_spre(1Hz) clock edge aligned to the reference clock edge.
When reference detection function is running while the external reference clock is removed
(no reference clock edge found in 3 ck_apre window), the calendar updating still can be
performed by LXTAL clock only. If the reference clock is recovered later, detection function
will use 7 ck_apre window to identify the reference clock and use 3 ck_apre window to adjust
the 1Hz clock (ck_spre) edge.