; **********************************************************
; SUB READS THE CLOCK AND WRITES IT TO THE SCRATCHPAD MEMORY
; ON RETURN FROM HERE DATE & TIME DATA WILL BE STORED IN THE
; DATE & TIME REGISTERS
; **********************************************************
READ_CLOCK:
MOV R1,#SECS ; SECONDS STORAGE LOCATION
MOV BYTECNT,#00H
CLR LASTREAD
CALL SEND_START
MOV A,#DS1307W
CALL SEND_BYTE
MOV A,#00H
CALL SEND_BYTE
CALL SEND_STOP
CALL SEND_START
MOV A,#DS1307R
CALL SEND_BYTE
READ_LOOP:
MOV A,BYTECNT
CJNE A,#09H,NOT_LAST
SETB LASTREAD
NOT_LAST:
CALL READ_BYTE
MOV @R1,A
MOV A,BYTECNT
CJNE A,#00H,NOT_FIRST
MOV A,@R1
CLR ACC.7 ; ENSURE OSC BIT=0 (ENABLED)
MOV @R1,A
NOT_FIRST:
INC R1
INC BYTECNT
MOV A,BYTECNT
CJNE A,#0AH,READ_LOOP
CALL SEND_STOP
RET
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&