GD32VF103 User Manual
234
Figure 15-12. Input capture logic
Synchronizer
D
presclare
Capture
Register
(
CH0VAL
)
Clock
Processer
Counter
Q
Filter
D
Q
D
Q
Edge Detector
CI1FE0
ITS
CH0MS
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
CH0_CC_I
CH0IF
CH0IE
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).
Result
:
When the wanted input signal is
captured, TIMERx_CHxCV will be set by counter’s
value and CHxIF is asserted. If the CHxIF is 1, the CHxOF will also be asserted. The
interrupt and DMA request will be asserted or not based on the configuration of CHxIE
and CHxDEN in TIMERx_DMAINTEN.