Digital clock based PIC16F877A !

Status
Not open for further replies.

ADDE

Newbie level 2
Joined
Apr 25, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
::))
Activity points
1,325
Hey all bros n Engineers(seniors) I am doing My course project n it looks it is completed and i have programed with PICC compiler n in simulation its running but in hardware nothin is displaying over the 2X16LCD n I am using PIC16f877A with Ds1302 and LM35..n need ur help see below the coding and also the schematic from proteus....
PLZ help i need it quichly thnz
.................................
#include<16f877.h> //Device
#fuses xt,nowdt,protect,noput,nolvp //Fuses
#use delay (clock=20000000) //20.00 MHz
#use rs232 (Baud=9600) //RS-232 parametres
//(only for printf function)
//#include"llcd_new.h" //LCD driver
#include<lcd.c>
#include "ds1302.h" //ds1302 driver
int day,mth,year,dow,h,m,s;
int a,b,c,d,e,x,y,z,v;

set_h() //set hour
{
while(!input(pin_b0)) //wait till button released
delay_ms(5);
while(1)
{
if(!input(pin_a4)&input(pin_b0)) //if button pressed
if(++d>23) //increase hours
d=0; //till < 24
delay_ms(200);
printf(lcd_putc,"\f%02u-%02u-20%02u",a,b,c);
printf(lcd_putc,"\n%02u:%02u:00",d,e);

rtc_set_datetime(a,b,c,0,d,e); //set date and time
delay_ms(50); //0-24h mode; 1-12h mode
x=1;
if(!input(pin_b0)) //return if button pressed
{delay_ms(100);
return(0);}
}
}

set_m() //set minute
{
while(!input(pin_b0))
delay_ms(5);
while(1)
{
if(!input(pin_a4)&input(pin_b0))
if(++e>59)
e=0;
delay_ms(200);
printf(lcd_putc,"\f%02u-%02u-20%02u",a,b,c);
printf(lcd_putc,"\n%02u:%02u:00",d,e);

rtc_set_datetime(a,b,c,0,d,e);
delay_ms(50);
y=1;
if(!input(pin_b0))
{delay_ms(100);
return(0);}
}
}

set_d() //set day
{
while(!input(pin_b0))
delay_ms(5);
while(1)
{
if(!input(pin_a4)&input(pin_b0))
if(++a>31)
a=0;
delay_ms(200);
printf(lcd_putc,"\f%02u-%02u-20%02u",a,b,c);
printf(lcd_putc,"\n%02u:%02u:00",d,e);

rtc_set_datetime(a,b,c,0,d,e);
delay_ms(50);
z=1;
if(!input(pin_b0))
{delay_ms(100);
return(0);}
}
}

set_mo() //set month
{
while(!input(pin_b0))
delay_ms(5);
while(1)
{
if(!input(pin_a4)&input(pin_b0))
if(++b>12)
b=0;
delay_ms(200);
printf(lcd_putc,"\f%02u-%02u-20%02u",a,b,c);
printf(lcd_putc,"\n%02u:%02u:00",d,e);

rtc_set_datetime(a,b,c,0,d,e);
delay_ms(50);
v=1;
if(!input(pin_b0))
{delay_ms(100);
return(0);}
}
}

set_y() //set year
{
while(!input(pin_b0))
delay_ms(5);
while(1)
{
if(!input(pin_a4)&input(pin_b0))
if(++c>99)
c=0;
delay_ms(200);
printf(lcd_putc,"\f%02u-%02u-20%02u",a,b,c);
printf(lcd_putc,"\n%02u:%02u:00",d,e);

rtc_set_datetime(a,b,c,0,d,e);
delay_ms(50);
v=1;
if(!input(pin_b0))
{delay_ms(100);
return(0);}
}
}

main()
{
a=0,b=0,c=0,d=0,e=0,x=0,y=0,z=0,v=0;

rtc_init(); //start ds1302
rtc_set_datetime(a,b,c,0,d,e); //set date and time
lcd_init();
while(1)
{
rtc_get_time(h,m,s); //read time
rtc_get_date(day,mth,year,dow); //read date

printf(lcd_putc,"\f%02u-%02u-20%02u",day,mth,year);
printf(lcd_putc,"\n%02u:%02u:%02u",h,m,s);
delay_ms(500);

if(!input(pin_b0))
set_h(); //set hour
if(!input(pin_b0)&x)
{while(!input(pin_b0)) //wait till button released
delay_ms(5);
set_m();} //set minute
if(!input(pin_b0)&y)
{while(!input(pin_b0))
delay_ms(5);
set_d();} //set day
if(!input(pin_b0)&z)
{while(!input(pin_b0))
delay_ms(5);
set_mo();} //set month
if(!input(pin_b0)&v)
{while(!input(pin_b0))
delay_ms(5);
set_y();} //set year
}
}
 

Kindly attach your schematics.
You have initilize some parameters wrong
like
#include<16f877.h> //Device
#fuses xt,nowdt,protect,noput,nolvp //Fuses
#use delay (clock=20000000) //20.00 MHz

instead of 16f877 you use 16f877A
instead of xt you have to use HS, XT is use if you use crystal less than 4Mhz.If you are using greater than 4Mhz than use HS.

Change these parameters and check the response.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…