passing data to LCD

Thread Starter

sri3di

Joined Mar 15, 2009
1
hi, I am looking for the LCD code of 16*2 line LCD with 8051.
i am using keil ,
the program which i have done is displaying the string but i am not able to display the values , please help me.

if i send a value it will display the junk value like σχΔεζ.



the code is.

main()
{
unsigned char colloc,rowloc;
P0=0x00; // P0 and P0 as output ports
P2=0x00;
writecmd(0x3C); // initialize LCD
writecmd(0x0E);
writecmd(0x01); // clear memory and home cursor
writestr("Wel-Come to LCD"); // write message in first line
writecmd(0xC4); // move cursor to second line 4th pos
writestr("Program");
}


void MSdelay(unsigned int value)
{
unsigned int x,y;
for(x=0;x<1275;x++)
for(y=0;y<value;y++);
}
void writecmd(unsigned char a)
{
busy(); // check for LCD is busy or not
rs = 0; // clear rs pin for command
rw = 0; // clear rw pin to write
P0 = a; // send command character
en = 1; // strob LCD
en = 0;
}
void writedat(unsigned char b)
{
busy(); // check for LCD is busy or not
rs = 1; // set rs pin for data
rw = 0; // clear rw pin to write
P0 = b; // send data character
en = 1; // strob LCD
en = 0;
}
void busy()
{
en = 0; // disable display
P0 = 0xFF; // configur P0 as input
rs = 0; // clear rs pin for command
rw = 1; // set rw pin to read
while(b==1)
{
en=0; // strob LCD till P0.7 is 1
en=1;
}
en=0;
}
void writestr(unsigned char *s)
{
unsigned char l,i;
l = strlen(s); // get the length of string
for(i=1;i<l;i++)
{
writedat(*s); // write every char one by one
s++;
}
}
 

AlexR

Joined Jan 16, 2008
732
Are you converting your values to ASCII characters before sending them to LCD?
The LCD can only display ASCII characters whereas numerical values are stored in your processor as binary numbers so before sending them to the LCD you have to convert them to ASCII strings.
 
Top