
Originally Posted by
Dennis
Also going to source a DS1307 and DS1337C tomorrow and later this week, will post an update asap.
Kind regards
Dennis
Dennis,
I'm using a DS1307, well one of MicroElektronica's RTC modules for the EasyPIC5 board and have the following example displaying time and date on a 16 x 2 LCD. I've only included the code for the RTC as there are loads of examples for hooking up an LCD.
Code:
SDA var PORTC.1 ' RTC data
SCL var PORTC.0 ' RTC clock
TRISC= %00000011
DB0 var byte[8]
CMCON = %00000111 ' Comparators = off
gosub write_1307
read_1307: ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
I2CREAD SDA,SCL,$D1,$00,[STR DB0\8] ' Read 8 bytes from DS1307
lcdout $fe,1,"Time=",hex2 DB0[2],":",hex2 DB0[1],":",hex2 DB0[0] 'bit 0=sec, bit 1=min, bit 2=hrs
lcdout $fe,$c0,"Date=",hex2 DB0[4],":",hex2 DB0[5],":",hex2 db0[6] 'bit 4=day, bit 5=month, bit 6=year
goto read_1307
end
Write_1307: ' Set time & date to 19:00:00 14th Feb 201
I2CWRITE SDA,SCL,$D0,$00,[$00,$00,$19,$7,$14,$2,$10,$90] ' Write to DS1307
pause 10
RETURN ' Sec Min Hr Day D M Y Control
I've had this running for some time in testing, and seems quite stable. One thing that needs developing further is a means of entering the date and time via push buttons or some other means, but at least you should be able to see the basic operation
Bookmarks