Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/18/04 07:32
Read: times


 
#72683 - RE: LCD initialize
Responding to: ???'s previous message
Hi here I am providing routines for initializing the LCD .

These may help you.


here E & RS are control lines, DB - data lines

//--------------------------------------------------
void writetoLCD(byte MSB4bits)
{

if(MSB4bits&0x80)
DB7=1;
else
DB7=0;
if(MSB4bits&0x40)
DB6=1;
else
DB6=0;

if(MSB4bits&0x20)
DB5=1;
else
DB5=0;

if(MSB4bits&0x10)
DB4=1;
else
DB4=0;
}

//------------------------------------------
void clrDisp()
{
RS=0;
E=1;
writetoLCD(0x00);
E=0;
_nop_();
E=1;
writetoLCD(0X10);
E=0;
_nop_();
E=1;
LCDDelay2();
LCDDelay2();
}
//-----------------------------------------------------

void LCDDelay1()
{
register word del;
del=0;
for(del=0;del<=0x200;del++)
_nop_();
}

//---------------------------------------- LCDDelay2 --void LCDDelay2()
{
register byte t1=0,t2=0;
for(t1=0;t1<0x32;t1++)
for(t2=0;t2<0xFF;t2++);
return;
}


void init_LCD() // This function Initializes the LCD module for a 4 bit driver.
{

RS=1;
E=1;
LCDDelay2();
LCDDelay2();
LCDDelay2();
LCDDelay2();
RS=0;
writetoLCD(0X30); //function set 1
E=0;
_nop_();
E=1;
LCDDelay2();
writetoLCD(0X30); //function set 2
E=0;
_nop_();
E=1;
LCDDelay1();
writetoLCD(0X30); //function set 3
E=0;
_nop_();
E=1;
LCDDelay2();
writetoLCD(0X20); //function set 4
E=0;
_nop_();
E=1;
writetoLCD(0X80); //function set 5
E=0;
_nop_();
E=1;
LCDDelay1();

writetoLCD(0X10); //cursor display shift

E=0;
_nop_();
E=1;
writetoLCD(0X40);
E=0;
_nop_();
E=1;

LCDDelay1();
writetoLCD(0X00); // display ON/OFF control
E=0;
_nop_();
E=1;
writetoLCD(0XC0);
E=0;
_nop_();
E=1;
LCDDelay1();
writetoLCD(0X00); //entry mode set
E=0;
_nop_();
E=1;
writetoLCD(0X60);
E=0;
_nop_();
E=1;
LCDDelay1();
clrDisp();

}


-sachin

List of 6 messages in thread
TopicAuthorDate
LCD initialize            01/01/70 00:00      
   RE: LCD initialize            01/01/70 00:00      
      RE: LCD initialize            01/01/70 00:00      
   RE: LCD initialize            01/01/70 00:00      
   RE: LCD initialize            01/01/70 00:00      
   RE: LCD initialize            01/01/70 00:00      

Back to Subject List