24
3886 Group
SINGLE-CHIP 8-BIT CMOS MICROCOMPUTER
MITSUBISHI MICROCOMPUTERS
TIMERS
The 3886 group has four timers: timer X, timer Y, timer 1, and
timer 2.
The division ratio of each timer or prescaler is given by 1/(n + 1),
where n is the value in the corresponding timer or prescaler latch.
All timers are count down. When the timer reaches “00
16
”, an un-
derflow occurs at the next count pulse and the corresponding
timer latch is reloaded into the timer and the count is continued.
When a timer underflows, the interrupt request bit corresponding
to that timer is set to “1”.
Timer 1 and Timer 2
The count source of prescaler 12 is the oscillation frequency di-
vided by 16. The output of prescaler 12 is counted by timer 1 and
timer 2, and a timer underflow sets the interrupt request bit.
Timer X and Timer Y
Timer X and Timer Y can each select in one of four operating
modes by setting the timer XY mode register.
(1) Timer Mode
The timer counts f(X
IN
)/16.
(2) Pulse Output Mode
Timer X (or timer Y) counts f(X
IN
)/16. Whenever the contents of
the timer reach “00
16
”, the signal output from the CNTR
0
(or
CNTR
1
) pin is inverted. If the CNTR
0
(or CNTR
1
) active edge se-
lection bit is “0”, output begins at “ H”.
If it is “1”, output starts at “L”. When using a timer in this mode, set
the corresponding port P5
4
( or port P5
5
) direction register to out-
put mode.
(3) Event Counter Mode
Operation in event counter mode is the same as in timer mode,
except that the timer counts signals input through the CNTR
0
or
CNTR
1
pin.
When the CNTR
0
(or CNTR
1
) active edge selection bit is “0”, the
rising edge of the CNTR
0
(or CNTR
1
) pin is counted.
When the CNTR
0
(or CNTR
1
) active edge selection bit is “1”, the
falling edge of the CNTR
0
(or CNTR
1
) pin is counted.
(4) Pulse Width Measurement Mode
If the CNTR
0
(or CNTR
1
) active edge selection bit is “0”, the timer
counts f(X
IN
)/16 while the CNTR
0
(or CNTR
1
) pin is at “H”. If the
CNTR
0
(or CNTR
1
) active edge selection bit is “1”, the timer
counts while the CNTR
0
(or CNTR
1
) pin is at “L”.
The count can be stopped by setting “1” to the timer X (or timer Y)
count stop bit in any mode. The corresponding interrupt request
bit is set each time a timer overflows.
The count source for timer Y in the timer mode or the pulse output
mode can be selected from either f(X
IN
)/16 or f(X
CIN
) by the timer
Y count source selection bit of the port control register 2 (bit 5 of
address 002F
16
).
Fig. 19 Structure of timer XY mode register
T
i
m
0
1
e
C
:
C
r
o
o
X
u
u
c
n
n
o
t
t
u
s
s
n
t
a
t
o
t
r
p
s
t
t
o
p
b
i
t
:
T
(
i
b
i
T
1
m
M
e
r
a
X
d
Y
d
r
m
e
o
s
d
s
e
0
0
r
e
2
g
3
1
i
s
6
)
t
e
r
:
T
i
b
m
b
e
r
Y
o
p
e
r
a
t
i
n
g
m
o
d
e
b
i
t
0
0
1
1
N
0
1
0
1
:
:
:
:
T
P
E
P
i
u
v
u
m
l
e
l
e
s
n
s
r
m
o
c
w
o
t
u
i
d
d
p
n
t
h
e
u
t
e
u
o
t
e
m
m
r
e
o
m
a
d
o
s
e
d
u
t
e
r
e
e
m
e
n
t
m
o
d
e
C
T
:
R
1
I
n
C
o
c
o
I
n
C
o
c
o
m
e
0
:
C
1
:
a
r
n
n
r
n
n
c
u
n
u
n
c
r
t
t
r
u
t
t
e
o
t
t
t
i
p
a
r
p
a
r
u
s
s
v
e
t
t
m
t
t
m
n
t
a
t
o
e
t
s
o
t
a
o
t
r
p
d
f
i
n
d
r
l
l
i
d
s
t
t
g
a
g
e
i
s
n
e
o
e
l
l
n
e
s
g
d
e
g
l
e
e
e
c
d
t
i
e
n
o
n
b
i
t
0
t
e
u
u
t
e
u
u
Y
o
o
u
e
a
r
i
i
g
i
e
v
e
n
t
1
:
a
f
i
n
g
e
d
e
g
d
e
g
e
i
n
g
e
v
e
n
t
b
7
C
N
T
:
R
0
I
n
C
o
c
o
I
n
C
o
c
o
a
r
n
n
r
n
n
c
r
t
t
r
u
t
t
e
t
i
p
a
r
p
a
r
v
e
t
t
m
t
t
m
e
t
s
o
t
a
o
d
f
i
n
d
r
l
l
i
d
g
a
g
e
i
s
n
e
e
l
l
n
e
s
g
d
e
g
l
e
e
e
c
d
t
i
e
n
o
n
b
i
t
0
t
e
u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