GD32F3x0 User Manual
353
CHxCAPFLT.
Step2: Edge selection. (CHxP/CHxNP in TIMERx_CHCTL2)
Rising or falling edge, choose one by CHxP/CHxNP.
Step3: Capture source selection. (CHxMS in TIMERx_CHCTL0)
As soon as you select one input capture source by CHxMS, you have set the channel
to input mode (CHxMS! =0x0) and TIMERx_CHxCV cannot be written any more.
Step4: Interrupt enable. (CHxIE in TIMERx_DMAINTEN)
Enable the related interrupt; you can get the interrupt.
Step5: Capture enables. (CHxEN in TIMERx_CHCTL2).
Result: When you wanted input signal is got, TIMERx_CHxCV will be set by Counter’s value.
And CHxIF is asserted. If the CHxIF is high, the CHxOF will be asserted also. The interrupt
will be asserted based on the configuration of CHxIE in TIMERx_DMAINTEN.
Direct generation: If you want to generate a DMA request or Interrupt, you can set CHxG by
software directly.
Channel output compare function
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
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.d
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
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.
The timechart Figure 16-51. Output-compare under three modes show the three compare
modes toggle/set/clear. CAR=0x63, CHxVAL=0x3