Specifications
II-42 EPSON S1C62N82 TECHNICAL SOFTWARE
CHAPTER 3: PERIPHERAL CIRCUITS (Timer)
• Checking timer edge
Label Mnemonic/operand Comment
LD X,TMSTAT ;Set address of the timer edge counter
CP MX,0 ;Check whether the timer edge
;counter is "0"
JP Z,RETURN ;Jump if "0" (Z-flag is "1")
LD Y,0E4H ;Set address of the timer
LD A,MY ;Read the data of TM0 to TM3
;into A register
LD Y,TMDTBF ;Set address of the timer data buffer
XOR MY,A ;Did the count on the timer
;change?
FAN MY,0100B ;Check bit D2 of the timer data buffer
LD MY,A ;Set the data of A register into
;the timer data buffer
JP Z,RETURN ;Jump, if the Z-flag is "1"
ADD MX,0FH ;Decrement the timer edge counter
;
RETURN: RET ;Return
This program takes a subroutine form. It is called at short
intervals, and decrements the data at address TMSTAT every
125 ms until the data reaches "0". The timing chart is
shown in Figure 3.7.2. The timer can be addressed using
the X register instead of the Y register.
TMSTAT and TMDTBF may be any address in RAM and not
involve a hardware function.
125 ms
Timer edge counter (TMSTAT) decrementing timing
TM2
Note
Fig. 3.7.2
Timing of the timer
edge counter