
Rev. 1.00
233 of 576
January 28, 2022
32-Bit Arm
®
Cortex
®
-M0+ MCU
HT32F54231/HT32F54241/HT32F54243/HT32F54253
14 General-Purpose T
imer (GPTM)
14 General-Purpose T
imer (GPTM)
Capture Counter Value Transferred to CHxCCR
When the channel is used as a capture input, the counter value is captured into the Channel
Capture/Compare Register (CHxCCR) when an effective input signal transition occurs. Once the
capture event occurs, the CHxCCIF flag in the INTSR register is set accordingly. If the CHxCCIF
bit is already set, i.e., the flag has not yet been cleared by software, and another capture event on
this channel occurs, the corresponding channel Over-Capture flag, named CHxOCF, will be set.
25
26
27
28
29
30
31
32
33
34
35
0
26
32
CNTR
CHxCCR
CHxCCIF
CHxOCF
GT_CH0
(TI0)
f
CLKIN
Figure 52. Input Capture Mode
Pulse Width Measurement
The input capture mode can be also used for pulse width measurement from signals on the GT_
CHx pins, TIx. The following example shows how to configure the GPTM operated in the input
capture mode to measure the high pulse width and the input period on the GT_CH0 pin using
channel 0 and channel 1. The basic steps are shown as follows.
▆
Configure the capture channel 0 (CH0CCS = 0x1) to select the TI0 signal as the capture input.
▆
Configure the CH0P bit to 0 to choose the rising edge of the TI0 input as the active polarity.
▆
Configure the capture channel 1 (CH1CCS = 0x2) to select the TI0 signal as the capture input.
▆
Configure the CH1P bit to 1 to choose the falling edge of the TI0 input as the active polarity.
▆
Configure the TRSEL bits to 0x1 to select TI0S0 as the trigger input.
▆
Configure the Slave controller to operate in the Restart mode by setting the SMSEL field in the
MDCFR register to 0x4.
▆
Enable the input capture mode by setting the CH0E and CH1E bits in the CHCTR register to 1.
As the following diagram shows, the high pulse width on the GT_CH0 pin will be captured into
the CH1CCR register while the input period will be captured into the CH0CCR register after input
capture operation.