![GigaDevice Semiconductor GD32E23 Series Скачать руководство пользователя страница 394](http://html.mh-extra.com/html/gigadevice-semiconductor/gd32e23-series/gd32e23-series_user-manual_2225794394.webp)
GD32E23x User Manual
394
CHxVAL 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 CHxVAL
register, the CHxIF bit is set and the channel (n) interrupt is generated if CHxIE = 1. And the
DMA request will be assert, if CHxDEN =1.
So the process can be divided to 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 high polarity by CHxP/CHxNP
* Enable the output by CHxEN
Step3:
Interrupt/DMA-request enables configuration by CHxIE/CHxDEN
Step4:
Compare output timing configuration by TIMERx_CAR and TIMERx_CHxCV
About the CHxVAL; you can change it ongoing to meet the waveform you expected.
Step5:
Start the counter by CEN.
The timechart below show the three compare modes toggle/set/clear. CAR=0x63,
CHxVAL=0x3
Figure 14-78. Output-compare under 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