
GD32L23x User Manual
118
Figure 5-1. CTC overview
Prescale
(/1,/2,/4,
,/128
)
CTC
Counter
TRIMVALUE
adjustment
Register
IR
C
48
M
PCLK1
APB1 BUS
USBD_SOF
CTC_SYNC
LXTAL
1'b0
CK_IRC48M
48MHz
10
00
01
11
REFSEL
REFPSC
SWREFPUL
RLVALUE
CKLIM
REF sync pulse
REFCAP
REFDIR
CTC
TRIMVALUE
Comparator
5.3.1.
REF sync pulse generator
Firstly, the reference signal source can select GPIO, LXTAL clock output, or USBSOF by
setting REFSEL bits in CTC_CTL1 register.
Secondly, the selected reference signal source use a configurable polarity by setting REFPOL
bit in CTC_CTL1 register, and can be divided to a suitable frequency with a configurable
prescaler by setting REFPSC bits in CTC_CTL1 register.
Thirdly, if a software reference pulse needed, write 1 to SWREFPUL bit in CTC_CTL0 register.
The software reference pulse generated in last step is logical OR with the external reference
pulse.
5.3.2.
CTC trim counter
The CTC trim counter is clocked by CK_IRC48M. After CNTEN bit in CTC_CTL0 register set,
and a first REF sync pulse detected, the counter start down-counting from RLVALUE (defined
in CTC_CTL1 register). If any REF sync pulse detected, the counter reload the RLVALUE and
start down-counting again. If no REF sync pulse detected, the counter down-count to zero,