GD32A50x User Manual
428
generated if it is enabled when CHxIE=1.
Figure 18-50. Channels input capture
principle
CI0
Synchronizer
D
Prescaler
Capture
Register
(
CH0VAL
)
Clock
Prescaler
Counter
TIMER_CK
Q
Filter
D
Q
D
Q
Edge Detector
CI1FE0
ITS
CH0MS
CH0IF
CH0IE
TIMERx_CC_INT
Capture INT From Other Channal
CH0CAPPSC
Edge selector
&inverter
Based on
CH0P&CH0NP
CI0FE0
Rising/Falling
ITI0
ITI3
ITI1
ITI2
IS0
CI0FE0
Rising&Falling
CI0F_ED
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 (just for CI0). 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 into 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.
Direct generation
: A DMA or interrupt request is generated by setting CHxG directly.