Pulse width modulation module UM0404
348/564 DocID13284 Rev 2
The duty cycle of the PWM output signal is controlled by the value in the respective pulse
width shadow register. This mechanism allows the selection of duty cycles from 0% to 100%
including the boundaries.
For a value of 0000h the output will remain at a high level, representing a duty cycle of
100%. For a value higher than the value in the period register the output will remain at a low
level, which corresponds to a duty cycle of 0%.
Figure 146 illustrates the operation and output waveforms of a PWM channel in mode 0 for
different values in the pulse width register. This mode is referred to as Edge Aligned PWM,
because the value in the pulse width shadow register only effects the positive edge of the
output signal. The negative edge is always fixed and related to the clearing of the timer.
Figure 146. Operation and output waveform in mode 0
17.1.2 Mode 1: symmetrical PWM generation (center aligned PWM)
Mode 1 is selected by setting the respective bit PMx in register PWMCON1 to ‘1’. In this
mode the timer PTx of the respective PWM channel is counting up until it reaches the value
in the associated period shadow register. Upon the next count pulse the count direction is
reversed and the timer starts counting down now with subsequent count pulses until it
reaches the value 0000h. Upon the next count pulse the count direction is reversed again
and the count cycle is repeated with the following count pulses.
The PWM output signal is switched to a high level when the timer contents are equal to or
greater than the contents of the pulse width shadow register while the timer is counting up.
The signal is switched back to a low level when the respective timer has counted down to a
value below the contents of the pulse width shadow register. So in mode 1 this PWM value
controls both edges of the output signal.
7
6
7
6
5
3
4
2
1
0
7
6
5
3
4
2
1
0
1
0
PPx
Period=7
PTx Count
Value
PWx Pulse
Width=0
PWx=1
PWx=2
PWx=4
PWx=6
PWx=7
PWx=8
Latch Shadow Registers
Interrupt Request
LSR
LSR
???? ????
100%
87.5%
75%
50%
25%
12.5%
0%
LSR