GD32W51x User Manual
515
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
* Enable the output by CHxEN
Step3:
Interrupt/DMA-request enables configuration by CHxIE/CxCDE
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-44. Output-compare in three modes
toggle/set/clear. CAR=0x63, CHxVAL=0x3
Figure 17-44. Output-compare in 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 outputs PWM waveform according to the TIMERx_CAR
registers and TIMERx_CHxCV registers.
Based on the counter mode, we have can also divide PWM into EAPWM (Edge aligned PWM)
and CAPWM (Centre aligned PWM).
The EAPWM period is determined by TIMERx_CAR and duty cycle is by TIMERx_CHxCV.
Figure 17-45. Timing chart of EAPWM
shows the EAPWM output and interrupts waveform.