![GigaDevice Semiconductor GD32E23 Series User Manual Download Page 335](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794335.webp)
GD32E23x User Manual
335
In output compare mode, the TIMERx can generate timed pulses with programmable
position, polarity, duration and frequency. When the counter matches the value in the
TIMERx_CHxCV register of an output compare channel, the channel (n) output can be set,
cleared, or toggled based on CHxCOMCTL. When the counter reaches the value in the
TIMERx_CHxCV register, the CHxIF bit will be set and the channel (n) interrupt is generated
if CHxIE = 1.
So, the process can be divided into several steps as below:
Step1:
Clock configuration. Such as clock source, clock prescaler and so on.
Step2:
Compare mode configuration.
Set the shadow enable mode by CHxCOMSEN.
Set the output mode (set/clear/toggle) by CHxCOMCTL.
Select the active polarity by CHxP.
Enable the output by CHxEN.
Step3:
Interrupt/DMA-request enables configuration by CHxIE.
Step4:
Compare output timing configuration by TIMERx_CAR and TIMERx_CHxCV.
The TIMERx_CHxCV can be changed onging to meet the expected waveform.
Step5:
Start the counter by configuring CEN to 1.
The timing chart below show the three compare modes toggle/set/clear. CAR=0x63,
CHxVAL=0x3
Figure 14-51. Output-compare in three modes
CEN
CNT_REG
00
01
02
03
04
05
…
.
62
63
Overf low
match toggle
CNT_CLK
OxCPRE
00
01
02
03
04
05
…
.
62
63
01
02
03
04
05
…
.
00
match set
match clear
OxCPRE
OxCPRE