Thursday, 4 February 2010

interfacing of the LCD module with 8051 P89V51RD2

#include
#include
#include

xdata volatile unsigned char rs _at_ 0xFE01;
xdata volatile unsigned char lcd _at_ 0xFE00;

void main()
{
init_lcd();
printlcd(" Ei Labz ");

while(1);

}
/*********************************************************
Function to initialize lcd
*********************************************************/
void init_lcd()
{
writecommand(0x38); //Two lines 5x7 matrix
writecommand(0x01); //Clear Display screen
writecommand(0x06); //Increment Cursor
writecommand(0x0c); //Display on cursor off
}
/*********************************************************/
/*********************************************************
Function to write COMMAND into lcd
*********************************************************/
void writecommand(unsigned char data1)
{
lcd=data1;
_nop_();
_nop_();

delay();
}
/*********************************************************/
/*********************************************************
Function to print a string data into lcd
*********************************************************/
void printlcd(unsigned char *str)
{
unsigned char len,i;

len=strlen(str);

for(i=0;i<=len-1;i++)
{
writedata(*str);
str++;
}
}

/*********************************************************/
void writedata(unsigned char data2)
{
rs=data2;
_nop_();
_nop_();

delay();
}
/*********************************************************
Function which causes some delay
*********************************************************/
void delay()
{
int k;

for(k=0;k<=9000;k++);
}

No comments:

Post a Comment