SINGLE-CHIP 8-BIT CMOS MICROCOMPUTER
MITSUBISHI MICROCOMPUTERS
7560 Group
25
Timer X
Timer X is a 16-bit timer that can be selected in one of four modes
and can be controlled the timer X write and the real time port by
setting the timer X mode register.
(1) Timer mode
The timer counts f(X
IN
)/16 (or f(X
CIN
)/16 in low-speed mode).
(2) Pulse output mode
Each time the timer underflows, a signal output from the CNTR
0
pin is inverted. Except for this, the operation in pulse output mode
is the same as in timer mode. When using a timer in this mode,
set the corresponding port P5
4
direction register to output mode.
(3) Event counter mode
The timer counts signals input through the CNTR
0
pin.
Except for this, the operation in event counter mode is the same
as in timer mode. When using a timer in this mode, set the corre-
sponding port P5
4
direction register to input mode.
(4) Pulse width measurement mode
The count source is f(X
IN
)/16 (or f(X
CIN
)/16 in low-speed mode). If
CNTR
0
active edge switch bit is
“
0
”
, the timer counts while the in-
put signal of CNTR
0
pin is at
“
H
”
. If it is
“
1
”
, the timer counts while
the input signal of CNTR
0
pin is at
“
L
”
. When using a timer in this
mode, set the corresponding port P5
4
direction register to input
mode.
G
Timer X Write Control
If the timer X write control bit is
“
0
”
, when the value is written in the
address of timer X, the value is loaded in the timer X and the latch
at the same time.
If the timer X write control bit is
“
1
”
, when the value is written in the
address of timer X, the value is loaded only in the latch. The value
in the latch is loaded in timer X after timer X underflows.
If the value is written in latch only, unexpected value may be set in
the high-order counter when the writing in high-order latch and the
underflow of timer X are performed at the same timing.
G
Real Time Port Control
While the real time port function is valid, data for the real time port
are output from ports P5
2
and P5
3
each time the timer X
underflows. (However, if the real time port control bit is changed
from
“
0
”
to
“
1
”
after set of the real time port data, data are output
independent of the timer X operation.) If the data for the real time
port is changed while the real time port function is valid, the
changed data are output at the next underflow of timer X.
Before using this function, set the corresponding port direction
registers to output mode.
I
Note on CNTR
0
interrupt active edge selection
CNTR
0
interrupt active edge depends on the CNTR
0
active edge
switch bit.
Fig. 20 Structure of timer X mode register
Timer X mode register
(TXM : address 0027
16
)
T
i
m
0
1
R
e
0
1
P
5
2
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