![GigaDevice Semiconductor GD32E23 Series User Manual Download Page 205](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794205.webp)
GD32E23x User Manual
205
13.3.8.
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 adjustment 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.
13.3.9.
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