okay, i'm using a PIC16F876A and a DS1307 RTC, i have written a short program which should set the time, then loop reading the time to confirm that it is infact set. the problem is when i go to run this in the device... the LCD screen just shows up values with everything reading "00". this to me suggests that i have something wrong with the write commands. here's the offending code:
TRISC = %11111111
TRISB = %11111111
second var byte
minute var byte
hour var byte
day var byte
date var byte
month var byte
year var byte
ITCDEVICE var byte
ITCADDRESS var byte
SDA var PORTC.4
CLK Var PORTC.3
LCDOUT var PORTB.0
ITCDEVICE = $D0
ITCADDRESS = $00
second = 0
minute = 0
hour = 12
day = 2
date = 25
year = 5
pause 1000
I2CWRITE SDA, CLK, ITCDEVICE, ITCADDRESS, [second, minute, hour, day, date, year]
second = 255 'change variables to make sure it recieves correctly'
minute = 255
hour = 255
day = 255
date = 255
year = 255
loop:
pause 500
I2CREAD SDA, CLK, ITCDEVICE, ITCADDRESS, [second, minute, hour, day, date, year]
serout LCDout, 6,[254,1] 'clears screen'
serout LCDout, 6,[254,128] 'sets position'
serout LCDout, 6,[#hour,":",#minute,":",#second] 'displays the read time
serout LCDout, 6,[254,192] 'next line'
serout LCDout, 6,["month:",#month," year:",#year] 'displays the read date
goto loop
Bookmarks