Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] LCD code explaination

Status
Not open for further replies.

bikashh

Full Member level 5
Joined
Nov 28, 2009
Messages
264
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,132
dear friends,
i've got a code for my 20 X 4 LCD for my project using LPC2368 microcontroller.and it is working fine but the below portion is not clear to me...please give some light on it..

code1:

//Initialization:
void LcdInit (void)
{
LCD_IO_init(); //pin configuration
DelayMs(15) ;
DelayMs(15) ;
DelayMs(15) ;
DelayMs(15) ;
LcdCmd1(0x03) ;
DelayMs(6) ;
DelayMs(6) ;
DelayMs(6) ;
DelayMs(6) ;
LcdCmd1(0x03) ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
LcdCmd1(0x03) ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
LcdCmd1(0x02) ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;

LcdCmd(0x28) ;
LcdCmd(0x08) ;
LcdCmd(0x0c) ;
LcdCmd(0x06) ;
ClearLine(1);
ClearLine(2);

}

code2://command
void LcdCmd1 (unsigned char cmd)
{
unsigned int temp ;
LCD_SET1 = temp = LCD_DATA & (cmd << 20) ;
LCD_CLR1 = (temp ^ LCD_DATA) | (LCD_RS | LCD_EN);

SmallDelay() ;
LCD_SET1 = LCD_EN ;
SmallDelay() ;
LCD_CLR1 = LCD_EN ;
SmallDelay() ;
}

void LcdCmd (unsigned char cmd)
{
LcdCmd1(cmd >> 4) ;
LcdCmd1(cmd) ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
Delay250() ;
}
queries:

code1:
LcdCmd1(0x03) ;
why 0x03?


code2:
what does the line means
LCD_CLR1 = (temp ^ LCD_DATA) | (LCD_RS | LCD_EN);


thanks in advance
 

This is the exclusive or operation,

0^0 = 0
0^1 = 1
1^0 = 1
1^1 = 0

the variables temp and LCD_DATA are exclusive ORed bit by bit (bit0 with bit0, bit1 with bit1 etc)
usually this kind of operation is used to invert one or more bits,
anything exclusive ORed with 1 is inverted (a 0 becomes 1, and 1 becomes 0)

Alex
 

but why do i need to do XORed
i only need to set the RS and than make EN high and low right?

tanks for the reply
 

but if you see the code

LcdCmd(0x06) is doing "Entry mode set"
likewise what 0x03 does i didn't get from the datasheet

thanks
 

You can check the initialization steps explained better in **broken link removed**

Alex
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top