hainguyen
Newbie level 1

Hi all,
I want to make a digital clock, include PIC16F88, LCD 16x2 and RTC DS1302.
I use CCS C complier, and driver for DS1302 is DS1302.C in C:\Program Files\PICC\Drivers. Here is the code:
Time and date have set already, but the the clock didn't work. Where is the problem in my program? Tks for your help.
I want to make a digital clock, include PIC16F88, LCD 16x2 and RTC DS1302.
I use CCS C complier, and driver for DS1302 is DS1302.C in C:\Program Files\PICC\Drivers. Here is the code:
Code:
void rtc_display()
{
// Hien thi gio
if (hour<10)
{
lcd_gotoxy(1,1);lcd_putc("0");
lcd_gotoxy(2,1);printf(lcd_putc,"%u",hour);
}
else
{
lcd_gotoxy(1,1);printf(lcd_putc,"%u",hour);
}
// Hien thi phut
if (min<10)
{
lcd_gotoxy(4,1);lcd_putc("0");
lcd_gotoxy(5,1);printf(lcd_putc,"%u",min);
}
else
{
lcd_gotoxy(4,1);printf(lcd_putc,"%u",min);
}
// Hien thi giay
if (sec<10)
{
lcd_gotoxy(7,1);lcd_putc("0");
lcd_gotoxy(8,1);printf(lcd_putc,"%u",sec);
}
else
{
lcd_gotoxy(7,1);printf(lcd_putc,"%u",sec);
}
}
void main()
{
rtc_init();
lcd_init();
while(1)
{
rtc_get_date(day,mth,year,dow);
rtc_get_time(hour,min,sec );
rtc_display();
delay_ms(500);
}
}
Time and date have set already, but the the clock didn't work. Where is the problem in my program? Tks for your help.
Last edited: