www.geehy.com Page 180
Output Compare
There are eight modes of output compare: freeze, channel x is valid level when
matching, channel x is invalid level when matching, flip, force is invalid, force is
valid, PWM1 and PWM2 modes, which are configured by OCxMOD bit in
TMRx_CCMx register and can control the waveform of output signal in output
compare mode.
Output compare application
In the output compare mode, the position, polarity, frequency and time of the
pulse generated by the timer can be controlled.
When the value of the counter is equal to that of the capture/compare register,
the channel output can be set as high level, low level or flip by configuring the
OCxMOD bit in TMRx_CCMx register and the CCxPOL bit in the output polarity
TMRx_CCEN register.
When CCxIFLG=1 in TMRx_STS register, if CCxIEN=1 in TMRx_DIEN register,
an interrupt will be generated; if CCDSEL=1 in TMRx_CTRL2 register, DMA
request will be generated.
PWM Output Mode
PWM mode is an adjustable pulse signal output by the timer. The pulse width of
the signal is determined by the value of the compare register CCx, and the cycle
is determined by the value of the auto reload AUTORLD.
PWM output mode contains PWM mode 1 and PWM mode 2; PWM mode 1 and
PWM mode 2 are divided into count-up, count-down and edge alignment
counting; in PWM mode 1, if the value of the counter CNT is less than the value
of the compare register CCx, the output level will be valid; otherwise, it will be
invalid.