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.

Check my code for data display in lcd

Status
Not open for further replies.

anupriya

Newbie level 5
Joined
Nov 30, 2004
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
103
data display in lcd

main()
{

char c='h';
int x=5;
write_char(c,x);
}

void write_instr(unsigned char instr)
{
RS=0;
RW=0;
E=0;
P3=instr>>4;
E=1;
E=0;
delay();
P3=instr&0x0F;
E=1;
E=0;
delay();
}

void write_char(char val,int p)
{
char d;
if(p=0 && p<=39)//if user given position is b/w this range then 1st line
{
write_instr(line1 + p);//the addr is added to the position value and the addr is incremented
delay();
}
else
{
write_instr(line2 + p);
delay();
}
d=val<<4;//the uppermost 4bit are taken and stored in d
E=0;
RW=1;
RS=0;
P3=d;//data is wrriten into the ddram
E=1;
RW=0;
lcd_delay();
d=(val&0x0F);
E=0;
RW=1;
P3=d;//data is eend to ddram
E=1;
RW=0;
delay();
write_instr(disp_home);//after the data is written the cursor comes to home position
delay();
}

is this correct.
plz somebody help
 

Re: data display in lcd

You did not specify where your LCD is connected (data and control lines).
If data and control is connected to P3 you can not do the routine like you have done because when you use P3=xxx you will overwrite the control lines.

And at least this is wrong:

d=val>>4;//the uppermost 4bit are taken and stored in d
E=0;
RW=1; // not needed
RS=0;
RW=0;
P3=d;//data is wrriten into the ddram
E=1;
lcd_delay();
d=(val&0x0F);
E=0;
RW=1; // not needed
RW=0;
P3=d;//data is eend to ddram
E=1;
delay();
E=0;


You also do not initialize the display for 4 bit mode ...

hope this helps and best regards
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top