Rich (BB code):
RTC:
call read_RTC
read_regs:
movf SECS,0
call writebcd
;movwf temp15
;movlw 0xCB
;movwf PORTD
;call SND_CMD
;movf temp15,0
;movwf PORTD
;call SND_DTA
return
read_RTC:
call I2C_STRT
movlw 0xD0
movwf I2C_Value
call I2C_SEND
movlw 0x00
movwf I2C_Value
call I2C_SEND
call I2C_STRT
movlw 0xD1
movwf I2C_Value
call I2C_SEND
movlw 0x00
movwf I2C_Value
call I2C_SEND
call I2C_RD
movwf SECS
call I2C_STP
return
writebcd:
movwf temp16
swapf temp16,0
andlw 0x0F
addlw 0x06
btfss STATUS,DC
call lessnine
addlw 0x31
goto digit1
lessnine:
addlw 0x2A
return
digit1:
movlw 0xCB
movwf PORTD
call SND_CMD
movf temp16,0
movwf PORTD
call SND_DTA
return
I2C_RD:
bcf STATUS,RP1
bsf STATUS,RP0
clrf TRISC
bsf TRISC,4
bcf STATUS,RP1
bsf STATUS,RP0
clrf I2C_Value
movlw 0x08
movwf COUNTER5
goto I2C_read_loop
;rlf I2C_Value,1
;clrf I2C_Value
I2C_read_loop:
rlf I2C_Value,1
bsf I2C_CLOCK
btfsc PORTC,4
bsf I2C_Value,0
bcf I2C_CLOCK
decfsz COUNTER5,1
goto I2C_read_loop
movf I2C_Value,0
return
Last edited by a moderator: