;****** rtc write routine *******
rtcwt:
lcall delay ; clk write
lcall strtc
mov a,#10100010b ;rtc write addr
lcall dsndrtc
mov a,#02h ;word addr
lcall dsndrtc
mov a,#00h
lcall dsndrtc
mov 0dh,#10100000b ;clk out
mov a,0dh
lcall dsndrtc
lcall stprtc
;****RTC start routine ****
strtc:
setb p1.3 ;initial condition
(set sda)
setb p1.2 ;set sclk pulse
clr p1.3 ;high to low
transmission of
data line
with high clock
clr p1.2 ;to transmite data
clear clock
ret
;**** RTC stop routine ****
stprtc:
clr p1.3 ;stop con
setb p1.2
setb p1.3
ret
;**** data tx for rtc bit by bit ****
Dsndrtc:
push 4fh
mov 4fh,#08h ;to transmit 8 bits
frt:
rlc a
jc her ;if carry set
go to "her"
clr p1.3 ;if carry low
clear data line
sjmp tyh
her:
setb p1.3 ;if carry high
set data line
tyh:
setb p1.2
clr p1.2
djnz 4fh,frt
ger:
setb p1.3 ;ack
setb p1.2
clr p1.2
pop 4fh
ret
end