I have checked the LCD separately using a sample code and it displays properly. So I decided to check the RTC separately and gave the code as below. The code executed correctly on Kiel Simulator. (it constantly displayed 16:55:58) However when I burnt the same code into the microcontroller and connected the hardware, there was no output on Hyper terminal.. ( I am not exactly sure how to use Hyper terminal) . PLease help me as I need to submit this as my project
//Program to interface RTC DS12C887 with 8051 microcontroller (AT89C51)
#include<reg51.h>
#include<absacc.h>
char hr, min, sec;
void delay(int time)
{
int i,j;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}
serial(char x) // Function to transmit data serially using RS232
{
SBUF=x;
while(TI==0);
TI=0;
}
void bcdconv(char mybyte) // Function to convert data into BCD format.
{
char x,y;
x=mybyte&0x0F;
x=x|0x30;
y=mybyte&0xF0;
y=y>>4;
y=y|0x30;
serial(y);
serial(x) ;
}
void main()
{
TMOD=0x20;
TH1=0xFD;
SCON=0X50;
TR1=1;
delay(220);
XBYTE[10]=0x20;
delay(20);
XBYTE[10]=0x30;
XBYTE[11]=0x83;
XBYTE[0]=0x55;
XBYTE[2]=0x58;
XBYTE[4]=0x16;
XBYTE[7]=0x02;
XBYTE[8]=0x02;
XBYTE[9]=0x02;
XBYTE[11]=0x03;
while(1)
{
XBYTE[10]=0x20;
delay(500);
hr=XBYTE[4];
bcdconv(hr);
serial(‘:’);
min=XBYTE[2];
bcdconv(min);
serial(‘:’);
sec=XBYTE[0];
bcdconv(sec);
serial(0x0D);
serial(0x0A);
}
}