GD32VF103 User Manual
288
the channel input, the current value of the counter is captured into the TIMERx_CHxCV
register, at the same time the CHxIF bit is set and the channel interrupt is generated if it is
enabled when CHxIE=1.
Figure 15-42. Input capture logic
CI0
Synchronizer
D
presclare
Capture
Register
(
CH0VAL
)
Clock
Processer
Counter
TIMER_CK
Q
Filter
D
Q
D
Q
Edge Detector
CI1FE0
ITS
CH0MS
CH0IF
CH0IE
CH0_CC_I
TIMERx_CC_INT
Capture INT From Other Channal
CH0CAPPSC
Edge selector
&inverter
Based on
CH0P&CH0NP
CI0FE0
Rising/Falling
ITI0
ITI3
ITI1
ITI2
CI0FED
Rising&Falling
IS0
CI0FED
The input signals of channelx (CIx) can be the TIMERx_CHx signal or the XOR signal of the
TIMERx_CH0, TIMERx_CH1 and TIMERx_CH2 signals. First, the input signal of channel (CIx)
is synchronized to TIMER_CK signal, and then sampled by a digital filter to generate a filtered
input signal. Then through the edge detector, the rising or falling edge is detected by
configuring CHxP bit. The input capture signal can also be selected from the input signal of
other channel or the internal trigger signal by configuring CHxMS bits. The IC prescaler makes
several input events generate one effective capture event. On the capture event,
TIMERx_CHxCV will store the value of counter.
So the process can be divided to several steps as below:
Step1:
Filter configuration (CHxCAPFLT in TIMERx_CHCTL0).
Based on the input signal and quality of requested signal, configure compatible
CHxCAPFLT.
Step2:
Edge selection (CHxP/CHxNP in TIMERx_CHCTL2).
Rising edge or falling edge, choose one by configuring CHxP/CHxNP bits.
Step3
:
Capture source selection (CHxMS in TIMERx_CHCTL0).
As soon as selecting one input capture source by CHxMS, the channel must be set to
input mode (CHxMS! =0x0) and TIMERx_CHxCV cannot be written any more.
Step4
:
Interrupt enable (CHxIE and CHxDEN in TIMERx_DMAINTEN).
Enable the related interrupt to get the interrupt and DMA request.
Step5
:
Capture enable (CHxEN in TIMERx_CHCTL2).