Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help on DS1302 RTC Programming

Status
Not open for further replies.

hainguyen

Newbie level 1
Joined
Jan 29, 2007
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
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:

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:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top