MCU User Forum
  help in Digital clock program

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   help in Digital clock program
rohanmartin08
New Member
posted August 02, 2010 02:39 AM     Click Here to See the Profile for rohanmartin08   Click Here to Email rohanmartin08     Edit/Delete Message
Hi all, I am designing a digital clock using 89C2051, 74LS595 and ULN2803 driver. The hardware is working fine, I need help with the program, I'm writing the code in keil C. Please help. The code is as below. but its not working properly.


#include
#include
#include

sbit PIN_P10=P1^0;
sbit PIN_P11=P1^1;
sbit PIN_P12=P1^2;
sbit CS4=P1^3;
sbit CS3=P1^4;
sbit CS2=P1^5;
sbit CS1=P1^6;


unsigned char DataWrite;
unsigned char _crol_(unsigned char Temp,unsigned char Datawrite);
char Display_Buffer[6];
unsigned char Dispcount;
unsigned char mscount;


int Hours=1;
int Minutes=0;
int Seconds=0;
int i=0;
char Temp;

code unsigned char Lookup[11]=
{
0xEE,0x28,0xCD,0x6C,0x2B,0x67,0xE7,0x2C,0xEF,0x2F
};


void main()
{

TMOD=0x01;
TH0=0xF8;
TL0=0x30;
IE=0x82;
TR0=1;


do
{

sprintf(Display_Buffer,"%02d%02d",Hours,Minutes);

}while(1);

}

void Timer0(void) interrupt 1
{
TF0=0;
TR0=0;
TH0=0xF8;
TL0=0x30;
TR0=1;


mscount++;
Dispcount++;
if(mscount>=1000)
{
mscount=0;
Seconds++;
}
if(Seconds>=59)
{
Seconds=0;
Minutes++;
}
if(Minutes>=59)
{
Minutes=0;
Hours++;
}
if(Hours>=12)
{
Hours=1;
}


{
if(Dispcount==29)
{
CS1=0;
CS2=0;
CS3=0;
CS4=0;
}
if(Dispcount==30)
{

DataWrite=Lookup[Display_Buffer[0]-0x30];

}



if(8>i)
{
i++;
if (Dispcount==32)
{
PIN_P11=1;
}
if (Dispcount==34)
{
Temp=DataWrite;
}
if (Dispcount==36)
{
PIN_P10=Temp^7;
}
if (Dispcount==38)
{
PIN_P11=0;
}
if (Dispcount==40)
{
DataWrite=_crol_(Temp,1);
}

}
PIN_P12=0;

if(Dispcount==48)
{
CS1=1;
}
}


{
if(Dispcount==49)
{
CS1=0;
CS2=0;
CS3=0;
CS4=0;
}
if(Dispcount==50)
{

DataWrite=Lookup[Display_Buffer[1]-0x30];

}

{

if(8>i)
{
i++;
if (Dispcount==52)
{
PIN_P11=1;
}
if (Dispcount==54)
{
Temp=DataWrite;
}
if (Dispcount==56)
{
PIN_P10=Temp^7;
}
if (Dispcount==58)
{
PIN_P11=0;
}
if (Dispcount==60)
{
DataWrite=_crol_(Temp,1);
}

}
PIN_P12=0;
}

if(Dispcount==68)
{
CS2=1;
}
}


{
if(Dispcount==69)
{
CS1=0;
CS2=0;
CS3=0;
CS4=0;
}
if(Dispcount==70)
{

DataWrite=Lookup[Display_Buffer[2]-0x30];

}

{

if(8>i)
{
i++;
if (Dispcount==72)
{
PIN_P11=1;
}
if (Dispcount==74)
{
Temp=DataWrite;
}
if (Dispcount==76)
{
PIN_P10=Temp^7;
}
if (Dispcount==78)
{
PIN_P11=0;
}
if (Dispcount==80)
{
DataWrite=_crol_(Temp,1);
}

}
PIN_P12=0;
}

if(Dispcount==88)
{
CS3=1;
}
}

{
if(Dispcount==89)
{
CS1=0;
CS2=0;
CS3=0;
CS4=0;
}
if(Dispcount==90)
{

DataWrite=Lookup[Display_Buffer[3]-0x30];

}

{

if(8>i)
{
i++;
if (Dispcount==92)
{
PIN_P11=1;
}
if (Dispcount==94)
{
Temp=DataWrite;
}
if (Dispcount==96)
{
PIN_P10=Temp^7;
}
if (Dispcount==98)
{
PIN_P11=0;
}
if (Dispcount==100)
{
DataWrite=_crol_(Temp,1);
}

}
PIN_P12=0;
}

if(Dispcount==108)
{
CS4=1;
}
}


if(Dispcount==821)
{
CS1,CS2,CS3,CS4=0;

}
}
RETI;

IP: Logged

Scotty
Member
posted August 02, 2010 04:56 AM     Click Here to See the Profile for Scotty     Edit/Delete Message
Hi rohanmartin08,

I am designing a digital clock using 89C2051
This forum is related to SiLabs parts, so I suggest you post your question on www.8052.com forum.

Regards,

Scotty

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b