
Originally Posted by
Jumper
Hi,
If you dont use a backup battery for the 1307 make sure that the un-used leg for the backup function is tied to ground. You can find this in the datasheet but if this is not done the chip will not work properly (sometimes it doesn't, other times it does but never when you want it to).
We are using the 1307 and it is doing fine.
TRIS? = %00000000 ' all pins to output just replace ? with port name
SDA var Port?.? 'define port for I2C communication replace ?.? with pin
SCL var Port?.?
Hours var Byte
Minutes var Byte
Seconds var Byte
RTC var Byte
I2C_Adr_B var byte
RTC = % 11010000 ' Device adress on I2C bus
I2C_Adr_B=0
I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[128,0,0,0,0,0,0,128] 'Reset time to 0 and stopped, 12 hour setting
Start_RTC:
I2C_Adr_B=0
I2CWRITE SDA,SCL,RTC,I2C_Adr_B,[0,0,0,0,0,0,0,16] 'Start RTC if you put a resistor and LED between the "SEC" pin and 5V it should start flash 1/s
return
RTC_Read:
I2C_Adr_B=0
I2CREAD SDA,SCL,RTC,I2C_Adr_B,[seconds,minutes, hours] ' in bcd code
return
call each part with a GOSUB
Good luck and enjoy
Bookmarks