
GD32L23x User Manual
119
and then up- counting to 128 x CKLIM (defined in CTC_CTL1 register), and then stop until
next REF sync pulse detected. If any REF sync pulse detected, the current CTC trim counter
value is captured to REFCAP in status register (CTC_STAT), and the counter direction is
captured to REFDIR in status register (CTC_STAT). The detail is showing as following figure.
Figure 5-2. CTC trim counter
CKOK
CKWARN
CKERR
CKWARN
REFMISS
0
+1
-1
+2
-2
CTC STATUS
TRIM VALUE
CKLIM
3 x CKLIM
128 x CKLIM
RLVALUE
Counter value
CLOCK
5.3.3.
Frequency evaluation and automatically trim process
The clock frequency evaluation is performed when a REF sync pulse occur. If a REF sync
pulse occurs on down-counting, it means the current clock is slower than correct clock (the
frequency of 48M).It needs to improve TRIMVALUE in CTC_CTL0 register. If a REF sync
pulse occurs on up-counting, it means the current clock is faster than correct clock (the
frequency of 48M).It needs to reduce TRIMVALUE in CTC_CTL0 register. The CKOKIF,
CKWARNIF, CKERR and REFMISS in CTC_STAT register shows the frequency evaluation
scope.
If the AUTOTRIM bit in CTC_CTL0 register is setting, the automatically hardware trim mode
enabled. In this mode, if a REF sync pulse occurs on down-counting, it means the current
clock is slower than correct clock, the TRIMVALUE will be increased automatically
to raise
the clock frequency. Vice versa when it occurs on up-counting, the TRIMVALUE will be
reduced automatically to reduce the clock frequency.
Counter < CKLIM when
REF sync pulse is detected.
The CKOKIF in
CTC_STAT register set, and an interrupt generated if CKOKIE bit in
CTC_CTL0 register is 1.