2-22
3802 GROUP USER’S MANUAL
APPLICATION
2.2 Timer
Figure 2.2.22 shows a control procedure.
(Address : 23
16
)
(Address : 24
16
)
(Address : 25
16
)
(Address : 3E
16
), bit4
(Address : 3C
16
), bit4
(Address : 3F
16
), bit0
(Address : 3D
16
), bit0
(Address : 23
16
), bit3
All interrupts : Disabled
G
XXXX
1011
2
256–1
256–1
1
0
1
0
0
~
RESET
Initialization
SEI
.
CNTR
0
interrupt processing routine
CLT (
Note 1
)
CLD (
Note 2
)
Push register to stack
RTI
Pop registers
Timer X interrupt processing routine
Processing for error
RTI
Error occurs
G
G
G
G
G
A count value is read out and stored to RAM.
Set the division ratio so that the Timer X
interrupt occurs every 250 ms.
G
G
TM
PREX
TX
ICON1
IREQ1
ICON2
IREQ2
.
TM
.
CLI
X :
This bit is not used in this application.
Set it to “0” or “1.” It’s value can be disregarded.
PREX
(A)
Result of pulse width measurement
low–order 8-bit
(A)
Result of pulse width measurement
high–order 8-bit
PREX (Address : 24
16
)
TX (Address : 25
16
)
Inversion of (A)
TX
256– 1
Inversion of (A)
256 – 1
Push the register used in the interrupt
processing routine into the stack.
Pop registers which is pushed to stack.
Timer X : Pulse width measurement mode
(Count “H” level width of pulse input from CNTR
0
pin.)
Set the division ratio so that the Timer X interrupt occurs
every 250 ms.
G
Timer X interrupt : Enabled
G
Note 1:
When using the Index X mode flag (T).
Note 2:
When using the Decimal mode flag (D).
CNTR
0
interrupt : Enabled
G
G
Timer X count : Operating
Interrupts : Enabled
G
Fig. 2.2.22 Control procedure [Measurement of pulse width]