![GigaDevice Semiconductor GD32E23 Series User Manual Download Page 334](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794334.webp)
GD32E23x User Manual
334
Step2
: Edge selection.(CHxP/CHxNP in TIMERx_CHCTL2).
Rising edge, falling edge or both edges (rising and 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 c
ounter’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 in
TIMERx_DMAINTEN.
Direct generation
: An interrupt is generated by setting CHxG directly.
The input capture mode can be also used for pulse period measurement from signals on the
TIMERx_CHx pins. For example, PWM signal connects to CI0 input. Select CI0 as channel 0
capture signals by setting CH0MS
to 2’b01 in the channel control register (TIMERx_CHCTL0)
and set capture on rising edge. The counter is set to restart mode and is restarted on
channel 0 rising edge. Then the TIMERX_CH0CV can measure the PWM period.
Channel output compare function
Figure 14-50. Channel output compare principle
Capture/
compare register
CH0CV
Counter
o
u
tp
u
t
co
m
p
a
ra
to
r
Compare output
control
CH0COMCTL
Output enable
and polarity
selector
CH0P,CH0E
O0CPRE
CH0_O
CNT>CH0CV
CNT=CH0CV
CNT<CH0CV
Figure 14-50. Channel output compare principle
shows the principle circuit of channels
output compare function. The relationship between the channel output signal CHx_O and the
OxCPRE signal (more details refer to
) is described as blew:
The active level of O0CPRE is high, the output level of CH0_O depends on OxCPRE signal,
CHxP bit and CH0P bit (please refer to the TIMERx_CHCTL2 register for more details).For
example, configure CHxP=0 (the active level of CHx_O is high, the same as OxCPRE),
CHxE=1 (the output of CHx_O is enabled):
If the output of OxCPRE is active(high) level, the output of CHx_O is active(high) level;
If the output of OxCPRE is inactive(low) level, the output of CHx_O is active(low) level.