
Rev. 1.00
301 of 486
July 31, 2018
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F50231/HT32F50241
16 Motor Control T
imer (MCTM)
Center-Aligned Counting
In the center-aligned counting mode, the counter counts up from 0 to the counter-reload value
and then counts down to 0 alternatively. The Timer Module generates an overflow event when the
counter counts to the counter-reload value in the up-counting mode and generates an underflow
event when the counter counts to 0 in the down-counting mode. The counting direction bit DIR
in the CNTCFR register is read-only and indicates the count direction when in the center-aligned
counting mode. The count direction is updated by hardware automatically.
Setting the UEV1G bit in the EVGR register will initialise the counter value to 0 irrespective of
whether the counter is counting up or down in the center-aligned counting mode.
The UEV1IF bit in the INTSR register can be set to 1 according to the CMSEL field setting in
the CNTCFR register. When CMSEL = 0x1, an underflow event will set the UEV1IF bit to 1.
When CMSEL = 0x2, an overflow event will set the UEV1IF bit to 1. When CMSEL = 0x3, either
underflow or overflow event will set the UEV1IF bit to 1.
CK_PSC
CNT_EN
F3
F4
4
CK_CNT
F2
F5
CNTR
CRR Shadow Register
CRR
4
F5
4
3
2
1
0
Counter Underflow
Update Event 1 Flag
Software clearing
Write a new value
Counter Overflow
1
2
3
Software clearing
Figure 96. Center-aligned Counting Example