76
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
(2) Event counter mode
In this mode, the timer counts an external signal or an internal timer’s overflow. Timers A0 and A1 can
count a single-phase external signal. Timers A2, A3, and A4 can count a single-phase and a two-phase
external signal. Table 17 lists timer specifications when counting a single-phase external signal. Figure
60 shows the timer Ai mode register in event counter mode.
Table 18 lists timer specifications when counting a two-phase external signal. Figure 61 shows the timer
Ai mode register in event counter mode.
Table 17. Timer specifications in event counter mode (when not processing two-phase pulse signal)
Item
Count source
External signals input to TAi
IN
pin (effective edge can be selected by software)
TB2 overflow, TAj overflow
Count operation
Up count or down count can be selected by external signal or software
When the timer overflows or underflows, the reload register's content is reloaded
and the timer starts over again.
(Note)
Divide ratio
1/ (FFFF
16
- n + 1) for up count
1/ (n + 1) for down count
Count start condition
Count start flag is set (= 1)
Count stop condition
Count start flag is reset (= 0)
Interrupt request generation timing
The timer overflows or underflows
TAi
IN
pin function
Programmable I/O port or count source input
TAi
OUT
pin function
Programmable I/O port, pulse output, or up/down count select input
Read from timer
Count value can be read out by reading timer Ai register
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)
Select function
Free-run count function
Even when the timer overflows or underflows, the reload register content is not reloaded to it
Pulse output function
Each time the timer overflows or underflows, the TAi
OUT
pin’s polarity is reversed
Note: This does not apply when the free-run function is selected.
i
m
e
r
A
i
m
o
d
e
r
e
g
i
s
t
e
r
y
m
b
o
l
A
d
d
r
e
s
s
T
A
i
M
R
(
i
=
0
,
1
)
0
3
9
6
1
0
3
9
0 1
0
Specification
n : Set value
B
i
t
n
a
m
e
F
u
n
c
t
i
o
n
T
7
N
o
t
e
1
:
I
(
T
V
:
W
t
n
a
d
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