Microcontroller › 8051 › Digital Clock using DS12C887
- This topic has 4 replies, 4 voices, and was last updated 12 years, 12 months ago by
anurudh tiwari.
-
AuthorPosts
-
December 29, 2011 at 9:01 am #1477
Shrimohan Ramchandra Jhawar
ParticipantI have written the code in Assembly Language to build a Digital Clock using DS12C887…But I am facing a problem in getting the exact output…
Initially as i set time i get output as (HH:MM:SS format)
16:58:01
16:58:02
03:03:03
58:58:04
and so on
The out put is very much unpredictable…please help me out
The code for the program appears as below…
I HAVE ALSO TRIED THE RTC CODE IN ENGINEERSGARAGE BUT IT ALSO DONT WORK AT MY END……
#include<reg51.h>
#include<absacc.h>#define port P3
#define lcd_dataport P2 // lcd_dataport for lcd
#define keypad P1 // Port for keypadpad
#define timeport P0 // Port for RTCsbit rs = port^0;
sbit rw = port^1;
sbit en = port^2;sbit key0=keypad^0;
sbit key1=keypad^1;
sbit key2=keypad^2;
sbit key3=keypad^3;
sbit key4=keypad^4;
sbit key5=keypad^5;
sbit key6=keypad^6;
sbit key7=keypad^7;int hr, min, sec;
void delay(unsigned int msec) //Time delay function
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}void lcdcmd(unsigned char item) //Function to send command to LCD
{
lcd_dataport = item;
rs= 0;
rw=0;
en=1;
delay(1);
en=0;
return;
}void lcddata(unsigned char item) //Funtion to send data on LCD
{
lcd_dataport = item;
rs= 1;
rw=0;
en=1;
delay(1);
en=0;
}void lcddata_string(unsigned char *str) // Function to send string on LCD
{
int i=0;
while(str!=’