GD32W51x User Manual
459
(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.
2)
Configure CHxNP=0 (the active level of CHx_ON is low, contrary to OxCPRE), CHxNE=1
(the output of CHx_ON is enabled),
If the output of OxCPRE is active(high) level, the output of CHx_O is active(low) level;
If the output of OxCPRE is inactive(low) level, the output of CHx_O is active(high) level.
When CH0_O and CH0_ON are output at the same time, the specific outputs of CH0_O and
CH0_ON are related to the relevant bits (ROS, IOS, POE and DTCFG bits) in the
TIMERx_CCHP register. Please refer to
for more details.
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 is set and the channel (n) interrupt is generated if CHxIE = 1. And the DMA
request will be asserted, if CxCDE=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/CxCDE
Step4:
Compare output timing configuration by TIMERx_CAR and TIMERx_CHxCV
About the TIMERx_CHxCV; you can change it on the go to meet the waveform you
expected.
Step5:
Start the counter by CEN.
Figure 17-15. Output-compare in three modes
toggle/set/clear. CAR=0x63, CHxVAL=0x3