
CHAPTER 7 8-BIT PWM TIMERS
94
7.4.4 8-bit PWM output operation
The PWM timer performs 8-bit PWM output operation when bit 6 of the 8-bit timer mode control register 5n (TMC5n)
is set to “1”, and outputs a pulse with a duty factor determined by the value set to the 8-bit compare register 5n (CR5n)
from the TIO5n pin.
Set the width of the active level of the PWM pulse to CR5n. The active level can be selected by bit 1 (TMC5n1)
of TMC5n.
The count clock can be selected by bits 0 through 2 (TCL5n0 through TCL5n2) of the timer clock select register
5n (TCL5n).
PWM output can be enabled or disabled by bit 0 (TOE5n) of TMC5n.
Caution CR5n can be rewritten only once in one cycle in the PWM mode.
Remark
n = 0 or 1
(1) Basic PWM output operation
[Setting]
(1) Set “0” to the port latch and port mode register n.
(2) Set the active level width by using 8-bit compare register 5n (CR5n).
(3) Select the count clock by using timer clock select register 5n (TCL5n).
(4) Select the active level by using bit 1 (TMC5n1) of TMC5n.
(5) The timer starts counting when bit 7 (TCE5n) of TMC5n is set to “1”.
To stop the counting, set “0” to TCE5n.
Remark
n = 0 or 1
[PWM output operation]
(1) When the timer starts counting, an inactive level is output from TIO5n as PWM output, until the timer
overflows.
(2) When the overflow occurs, the active level set in (1) in [Setting] above is output. The active level is
continuously output until the CR5n and the count value of the 8-bit counter 5n (TM5n) coincide.
(3) The inactive level is output after CR5n and the count value have coincided, until an overflow occurs
again.
(4) After that, (2) and (3) are repeated, until the counting operation is stopped.
(5) PWM output is deasserted inactive when the counting operation is stopped by clearing TCE5n to 0.
Remark
n = 0 or 1