
252
CHAPTER 10 TIMERS/COUNTERS 2 AND 3
10.7.4 PPG output
(1) Basic operation of PPG output
This function is to output a square wave whose pulse width is determined by the value of one compare register with
the cycle of the wave determined by another compare register. In other words, the PWM cycle of the PWM output
is varied.
To use this function, the timer unit mode register 2 (TUM2) must be set as shown in Tables 10-9 and 10-10. Tables
10-9 and 10-10 shows combinations between compare registers and timer outputs, and how to set the PPG output
function.
Table 10-9. Setting PPG Output (timer/counter 2)
Pulse Cycle
Pulse Width
Timer Output
Setting
CM21
CM20
TO20
Set TOM20 of TUM2 to 1 and CLR21 and CLR20 to 10 (TM2 is
cleared by match with CM21) (refer to
Figure 10-2
).
CM20
CM21
TO21
Set TOM21 of TUM2 to 1 and CLR21 and CLR20 to 01 (TM2 is
cleared by match with CM20) (refer to
Figure 10-2
).
Table 10-10. Setting PPG Output (timer/counter 3)
Pulse Cycle
Pulse Width
Timer Output
Setting
CM31
CM30
TO30
Set TOM30 of TUM2 to 1 and CLR31 and CLR30 to 10 (TM3 is
cleared by match with CM31) (refer to
Figure 10-2
).
CM30
CM31
TO31
Set TOM31 of TUM2 to 1 and CLR31 and CLR30 to 01 (TM3 is
cleared by match with CM30) (refer to
Figure 10-2
).
The pulse cycle and pulse width are as follows:
(a) When pulse cycle is set to CM21, and pulse width, to CM20
PPG cycle = (CM21 + 1)
¥
x/f
CLK
: x = 4, 8, 16, 32, 64
PPG pulse width = CM20
¥
x/f
CLK
where, 1 - CM20 < CM21
Note
Duty =PPG pulse width=
PPG cycle
CM20
CM21 + 1
Note
CM20 = CM21 is prohibited.
(b) When pulse cycle is set to CM20, and pulse width, to CM21
PPG cycle = (CM20 + 1)
¥
x/f
CLK
: x = 4, 8, 16, 32, 64
PPG pulse width = CM21
¥
x/f
CLK
where, 1 - CM21 < CM20
Note
Duty =PPG pulse width=
PPG cycle
CM21
CM20 + 1
Note
CM20 = CM21 is prohibited.