GD32W51x User Manual
557
* 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 on the go to meet the waveform you expected.
Step5:
Start the counter by CEN.
Figure 17-61. Output-compare under three modes
toggle/set/clear. CAR=0x63, CHxVAL=0x3
Figure 17-61. Output-compare under three modes
CEN
CNT_REG
00
01
02
03
04
05
.
62
63
Overflow
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
PWM mode
In the output PWM mode (by setting the CHxCOMCTL bits to 3’b110 (PWM mode0) or to 3’b
111(PWM mode1), the channel can generate PWM waveform according to the TIMERx_CAR
registers and TIMERx_CHxCV registers.
The period is determined by TIMERx_CAR and duty cycle is determined by TIMERx_CHxCV.
Figure 17-62. PWM mode timechart
shows the PWM output mode and interrupts waveform.
If TIMERx_CHxCV is greater than TIMERx_CAR, the output will be always active under PWM
mode0 (CHxCOMCTL==3’b110).