135
Chapter 7 Timer/Counter Units
7
(4) PWM output operation
In PWM output operation, a pulse signal with a duty factor determined by the value set in a compare register
is output. (See Fig. 7-35.)
The duty factor of a PWM output signal can be changed in steps of 1/65536 from 1/65536 to 65535/65536.
In addition, 16-bit timer 0 (TM0) has two compare registers, so that two types of PWM signals can be output.
Fig. 7-36 shows the setting of control registers. Fig. 7-37 shows the setting procedure. Fig. 7-38 shows the
procedure for changing the duty factor of PWM output.
Fig. 7-35 Example of PWM Signal Output by 16-Bit Timer/Counter
FFFFH FFFFH FFFFH
CR00 CR00 CR00
Timer starts
0H
TM0
count value
(active low)
TO0
Fig. 7-36 Setting of Control Registers for PWM Output Operation
(a) Timer control register 0 (TMC0)
(b) Capture/compare control register 0 (CRC0)
76543210
100 0
000
1
CRC0
Disables clearing TM0
Both TO0 and TO1 are used for
PWM output
(c) Timer output control register (TOC)
(d) Port 3 mode control register (PMC3)
76543210
TOC 11
××××××
TO0 for low-active PWM signal output
Enables PWM output for TO0
76543210
××× ××××
1
PMC3
Specifies P34 pin as TO0
output
76543210
00 0
000
1
TMC0
Overflow flag
Enables counting TM0
×