
72
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
Timer A
Figure 55 shows the block diagram of timer A. Figures 56 to 58 show the timer A-related registers.
Except in event counter mode, timers A0 through A4 all have the same function. Use the timer Ai mode
register (i = 0 to 4) bits 0 and 1 to choose the desired mode.
Timer A has the four operation modes listed as follows:
Timer mode: The timer counts an internal count source.
Event counter mode: The timer counts pulses from an external source or a timer's over flow.
One-shot timer mode: The timer stops counting when the count reaches “0000
16
”.
Pulse width modulation (PWM) mode: The timer outputs pulses of a given width.
Figure 55. Block diagram of timer A
Figure 56. Timer A-related registers (1)
C
o
u
n
t
e
r
(
U
1
6
A
i
n
)
c
C
o
u
d
n
d
t
r
s
e
t
s
a
s
r
t
0
f
3
l
a
8
g
0
1
(A
o
6
)
p
o
w
e
u
a
v
n
y
e
t
s
n
/
d
d
t
o
o
c
w
w
o
n
n
u
c
t
o
c
e
u
u
r
n
n
m
t
T
e
e
e
e
e
A
r
r
r
r
r
i
A
8
8
8
8
8
d
7
1
9
1
B
1
D
1
F
1
d
6
0
6
0
6
0
6
0
6
0
r
e
s
3
3
3
3
3
s
8
8
8
8
8
e
s
6
1
8
1
A
1
C
1
E
1
T
e
e
e
e
e
A
r
r
r
r
r
j
A
A
A
A
A
T
m
m
m
m
m
A
e
e
e
e
e
k
r
r
r
r
r
T
T
T
T
T
T
A
m
m
m
m
m
i
O
e
e
e
e
e
U
r
r
r
r
r
T
3
A
A
A
A
T
T
T
T
T
i
i
i
i
i
m
m
m
m
m
A
A
A
A
A
0 0
1 0
2 0
3 0
4
0
3
3
3
3
3
6
T
T
T
T
T
i
i
i
i
i
m
m
m
m
m
4
0
1
2
3
T
T
T
T
T
i
i
i
i
i
A
A
A
A
A
1
2
3
4
0
i
i
i
i
i
A
6
4
0
1
2
6
6
6
l
o
t
o
e
d
x
e
c
e
p
t
n
R
e
l
o
a
d
r
e
g
i
s
t
e
r
(
1
6
)
L
8
o
w
b
-
s
o
r
d
e
r
i
t
H
8
i
g
b
h
i
t
-
o
r
d
e
r
s
C
s
l
o
l
c
e
k
c
i
s
o
o
n
u
r
c
e
e
t
T
(
i
m
a
e
e
r
f
g
t
u
n
c
t
i
o
n
)
T
i
m
n
W
e
M
r
s
O
P
e
h
o
t
f
1
f
8
f
3
f
C
2
3
E
t
r
x
t
e
g
r
e
n
r
a
l
i
g
T
(
A
i
i
I
N
0
=
t
o
4
)
T
A
(
j
A
(
k
B
2
o
v
e
r
f
l
o
w
E
v
e
n
t
c
o
u
n
t
e
r
2
C
l
o
c
k
s
e
l
e
c
t
i
o
n
T
j
i
o
-
v
1
e
.
r
f
l
o
o
w
t
e
=
N
,
h
o
w
e
v
e
r
,
t
h
a
t
j
=
4
w
h
e
n
i
=
0
)
P
u
l
s
e
o
u
t
p
u
t
T
o
g
g
l
e
f
l
i
p
-
f
l
o
p
T
(
A
i
i
O
0
U
t
T
o
=
4
)
D
a
t
a
b
u
s
l
o
w
-
o
r
d
e
r
b
i
t
s
D
a
t
a
b
u
s
h
i
g
h
-
o
r
d
e
r
b
i
t
s
U
(A
p
d
/
d
d
r
o
e
w
s
n
s
0
f
l
3
a
g
8
D
w
n
c
o
u
n
t
4
1
6
)
T
k
i
o
+
v
e
1
r
f
N
l
o
o
w
t
e
=
.
,
h
o
w
e
v
e
r
,
t
h
a
t
k
=
0
w
h
e
n
i
=
4
)
P
s
o
l
l
a
c
r
i
t
i
y
o
n
e
e
t
Timer Ai mode register
Symbol
TAiMR(i=0 to 4)
Address
When reset
00
16
0396
16
to 039A
16
Bit name
Function
Bit symbol
TMOD0
A
b7
b6
b5
b4
b3 b2
b
1
b0
0 1 : Event counter mode
1 0 : One-shot timer mode
1 1 : Pulse width modulation
(PWM) mode
b1 b0
TCK1
MR3
MR2
MR1
TMOD1
MR0
TCK0
Function varies with each operation mode
Count source select bit
(Function varies with each operation mode)
Operation mode select
bit
AA
AA
AA
AA
A
A
A