#include <16F877A.h>
#device *=16
#device ICD=TRUE
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES WRT_50% //Lower half of Program Memory is Write Protected
#use delay(clock=18432000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#ifndef DS1337_SDA
#define DS1337_SDA PIN_C4
#define DS1337_SCL PIN_C3
#endif
#use i2c(master, sda=DS1337_SDA, scl=DS1337_SCL)
#include <LCD.C>
#include "ds1337.h"
// Main Program
void main(void)
{
date_time_t dt;
ds1337_init();
dt.month = 12; // December
dt.day = 31; // 31
dt.year = 06; // 2006
dt.hours = 23; // 23 hours (11pm in 24-hour time)
dt.minutes = 59; // 59 minutes
dt.seconds = 50; // 50 seconds
ds1337_set_datetime(&dt);
DS1337_read_datetime(&dt);
lcd_init();
printf("Start\n\r");
while(true)
{
delay_ms(300);
ds1337_read_datetime(&dt);
printf(lcd_putc,"\f\%02d/\%02d/\%02d\n",dt.day,dt.month,dt.year);
printf(lcd_putc,"\%02d:\%02d:\%02d", dt.hours,dt.minutes,dt.seconds);
}
}