Mitsubishi Motors DS5000TK User Manual
Page 156
![background image](/manuals/123320/156/background.png)
USER’S GUIDE
050396 155/173
156
lcall
CLOSE
;Close date/time registers.
mov
IE,
#0
mov
TMOD,
#20H
;Initialize the
mov
TH1,
#0FAH
;serial port
mov
TL1,
#0FAH
;for 9600
orl
PCON,
#80H
;baud using 11.0592 MHz crystal.
mov
SCON,
#52H
mov
TCON,
#40H
L:
jnb
RI,
L
;Wait for character.
clr
RI
;Clear the receiver.
mov
A,
SBUF
;Load in the character.
cjne
A, #’R, H
;Skip if not a read.
lcall
OPEN
;Set up to read date/time.
mov
B
#8
;Set up to send 8 bytes.
F:
lcall
RBYTE
;Read a byte of date/time.
G:
jnb
TI,
G
;Wait for end of previous send.
clr
TI
;Clear transmitter.
mov
SBUF,
A
;Send out the byte.
djnz
B,
F
;Loop for 8 bytes.
sjmp
L
;Return to main loop.
H:
cjne
A, #’W’, J
;Skip if not a write.
lcall
OPEN
;Set up to read date/time.
mov
B,
#8
; Set up to receive 8 bytes.
I:
jnb
RI,
I
;Wait to receive a byte.
clr
RI
;Clear the receiver.
mov
A,
SBUF
;Bring in the byte.
lcall
WBYTE
;Write a byte of date/time.
djnz
B,
I
;Loop for 8 bytes.
sjmp
L
;Return to main loop.
J:
jnb
TI,
J
;If it is neither an R nor a W
clr
TI
;increment the character,
inc
A
;send it back out to the
mov
SBUF,
A
;serial port, and then
sjmp
L
;return to the main loop.
;
;
; SUBROUTINE TO OPEN THE CLOCK/CALENDAR (ECC)
;
; This subroutine executes the sequence of reads and writes which
; is required in order to open communication with the timekeeper.
; The subroutine returns with the timekeeper opened for data
; access with both the accumulator and B register modified.
;