help me its urgent- characters are printed randomly

Status
Not open for further replies.

nvprnth

Newbie level 3
Joined
Dec 26, 2008
Messages
3
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,300
help me its urgent

hi
i happen to be doing a small assignment ,for which i have to interface an lcd to a microcontroller

here i am using a ds89c450 microcontroller

my program is
#include<reg420.h>
sfr ldata= 0x90;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
void lcdcmd(unsigned char value);
void msdelay(unsigned int itime);
void lcdinit();
void lcddata( unsigned char *value);

void main()
{

lcdinit();

lcdcmd(0x81);
msdelay(250);
lcddata("hello lcd ");
msdelay(250);



while(1)
{

}

void lcdcmd(unsigned char value)
{
en=0;
rs=0;
rw=0;

ldata=value;

en=1;

msdelay(250);
en=0;
return;
}


void lcddata( unsigned char *value)
{
while(*value)
{
en=0;
rs=1;
rw=0;
ldata=*value;

en=1;

msdelay(350);
en=0;
value++;
}
return;
}
void msdelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}

void lcdinit()
{
lcdcmd(0x38);
msdelay(250);
lcdcmd(0x0E);
msdelay(250);
lcdcmd(0x80);
msdelay(250);
}


as i burn this and look for o/p i am getting it but the characters are printed randomly at whatever place it wants ,like the printing starts at a 2ndline middle, or someother case, in some cases only few characters are visble

can u please help me out plzzzzzz i need do it fast,waiting for reply
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…