80
TimerA
M
i
t
s
u
M
S
b
i
s
3
M
h
0
I
C
i
m
2
R
i
1
O
c
r
8
C
o
c
o
G
M
m
p
r
P
u
t
u
T
e
r
p
R
s
o
U
S
I
N
G
L
E
-
C
H
I
P
1
6
-
B
I
T
C
M
O
O
E
(4) Pulse width modulation (PWM) mode
In this mode, the timer outputs pulses of a given width in succession. (See Table 20.) In this mode, the counter
functions as either a 16-bit pulse width modulator or an 8-bit pulse width modulator. Figure 63 shows the timer
Ai mode register in pulse width modulation mode. Figure 64 shows the example of how a 16-bit pulse width
modulator operates. Figure 65 shows the example of how an 8-bit pulse width modulator operates.
Table 20. Timer specifications in pulse width modulation mode
Item
Count source
f
1
, f
8
, f
32
, f
C32
Count operation
The timer counts down (operating as an 8-bit or a 16-bit pulse width modulator)
The timer reloads a new count at a rising edge of PWM pulse and continues counting
The timer is not affected by a trigger that occurs when counting
16-bit PWM
High level width
n / fi
Cycle time
(2
16
-1) / fi fixed
8-bit PWM
High level width n X (m+1) / fi
n : values set to timer Ai register’s high-order address
Cycle time (2
8
-1) X (m+1) / fi
m : values set to timer Ai register’s low-order address
Count start condition
External trigger is input
The timer overflows
The count start flag is set (= 1)
Count stop condition
The count start flag is reset (= 0)
Interrupt request generation timing
PWM pulse goes “L”
TAi
IN
pin function
Programmable I/O port or trigger input
TAi
OUT
pin function
Pulse output
Read from timer
When timer Ai register is read, it indicates an indeterminate value
Write to timer
When counting stopped
When a value is written to timer Ai register, it is written to both reload
register and counter
When counting in progress
When a value is written to timer Ai register, it is written to only reload register
(Transferred to counter at next reload time)
Figure 63. Timer Ai mode register in pulse width modulation mode
Specification
n : Set value
T
7
i
m
6
e
r
A
i
4
m
o
3
d
e
2
1
r
e
1
1
g
i
0
1
s
t
e
r
S
T
y
m
i
M
b
o
R
l
(
A
d
6
d
t
r
o
e
s
0
s
3
W
h
e
0
n
0
1
r
e
6
s
e
t
A
i
=
0
t
o
4
)
0
3
9
6
1
9
A
1
6
B
i
t
n
a
m
e
F
u
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