Does anyone know how to interface to the DS1307 with an 18Fxxx series?
I am using a PIC18F6620 @ 20MHz. On the DS1307 I have 2 10K pullups on SDA & SCL and an XTAL @ 32,768kHz. Below is sample code I have written just as a test program. My LCD reads zeros when I try to read the data. I have followed several examples in this archive but nothing seems to work! I have even replace the chip and nothing.
thanks in advance for your help!
DEFINE OSC 20
DEFINE I2C_SLOW 1
SCL var PORTF.4
SDA var PORTF.5
mins var byte
hr var byte
day var byte
date var byte
month var byte
year var byte
TRISF=0
Start:
I2CWRITE SDA,SCL,$D0,$00,[$00,$00,$12,$02,$16,$03,$05]
pause 10
I2CREAD SDA,SCL,$D1,$01[Mins,Hr,Day,Date,Month,Year]
pause 10
debug PlaceCursor,78," DATE & TIME ",PlaceCursor,105,126,"1. Time: ",hex Hr,":",hex2 Mins,PlaceCursor,145," 2. Date: ",PlaceCursor,158,",",hex2 Month,"/", hex2 Date ,"/",hex2 year
goto start
Bookmarks