PDA

View Full Version : DS1307 help



Orlando
- 16th March 2005, 23:51
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

NavMicroSystems
- 17th March 2005, 00:47
Orlando,

an excellent example can be found here (http://www.melabs.com/resources/samples/submitted/MN1307.txt)

and please see this: this (http://www.picbasic.co.uk/forum/showthread.php?t=1254)

Melanie
- 17th March 2005, 15:17
Also drop those 10K's down to 4K7.