English
Language : 

M38002M4 Datasheet, PDF (70/173 Pages) Mitsubishi Electric Semiconductor – 8-BIT SINGLE-CHIP MICROCOMPUTER
APPLICATION
2.2 Timer
Figure 2.2.22 shows a control procedure.
RESET
Initialization
SEI
TM (Address : 2316)
XXXX10112
PREX (Address : 2416)
256–1
TX (Address : 2516)
256–1
ICON1(Address : 3E16), bit4
1
IREQ1 (Address : 3C16), bit4 0
ICON2(Address : 3F16), bit0
1
IREQ2 (Address : 3D16), bit0 0
TM (Address : 2316), bit3
0
CLI
q X : This bit is not used in this application.
Set it to “0” or “1.” It’s value can be disregarded.
q All interrupts : Disabled
q Timer X : Pulse width measurement mode
(Count “H” level width of pulse input from CNTR0 pin.)
q Set the division ratio so that the Timer X interrupt
occurs every 250 ms.
q Timer X interrupt : Enabled
q CNTR0 interrupt : Enabled
q Timer X count : Start
q Interrupts : Enabled
Timer X interrupt processing routine
Processing for error
RTI
q Error occurs
CNTR0 interrupt processing routine
CLT (Note 1)
CLD (Note 2)
Push register to stack
(A)
Result of pulse width measurement
low–order 8-bit
(A)
Result of pulse width measurement
high–order 8-bit
PREX (Address : 2416)
TX (Address : 2516)
PREX
Inversion of (A)
TX
Inversion of (A)
256 – 1
256 – 1
Note 1: When using the Index X mode flag (T).
Note 2: When using the Decimal mode flag (D).
q Push the register used in the interrupt
processing routine into the stack.
q A count value is read out and stored to RAM.
q Set the division ratio so that the Timer X
interrupt occurs every 250 ms.
Pop registers
RTI
q Pop registers which is pushed to stack.
Fig. 2.2.22 Control procedure [Measurement of pulse width]
2-22
3800 GROUP USER’S MANUAL