
159
CHAPTER 8 8-BIT PWM TIMERS
User
’
s Manual U15017EJ2V0UD
8.4.4 8-bit PWM output operation
The PWM timer performs 8-bit PWM output operation when bit 6 (TMC5n6) of 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 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 to 2 (TCL5n0 to TCL5n2) of 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) Write 0 to the port latch and port mode register for a port that also functions as a timer output pin.
(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) Set bit 0 (TOEn) of TMC5n to 1 to enable timer output.
(6) 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 is output. The active level is continuously output until the
CR5n and the count value of 8-bit timer counter 5n (TM5n) match.
(3) The inactive level is output after CR5n and the count value have matched, 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