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.

lcd interfacing with 8051 microcontroller

Status
Not open for further replies.

svinoth86

Newbie level 6
Joined
Nov 13, 2010
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,420
how to interface lcd with 8051?...............

---------- Post added at 12:46 ---------- Previous post was at 12:46 ----------

#include <REGX51.H>
sbit rs=P3^5;
sbit rw=P3^6;
sbit en=P3^7;
delay(unsigned int i)
{
while(i--);
}
lcd_cmd(unsigned char c)
{
P1=c;
rs=0;
rw=0;
en=1;
delay(150);
en=0;
}
lcd_data(unsigned char c)
{
P1=c;
rs=1;
rw=0;
en=1;
delay(150);
en=0;
}
lcd_init()
{
lcd_cmd(0x38);
lcd_cmd(0x0c);
lcd_cmd(0x01);
lcd_cmd(0x80);

}

void main()
{
int i;
lcd_init();
for(i=0;i<=16;i++)

{
lcd_cmd(0x01);
lcd_cmd(0x80+i);
lcd_data( "VINOTH");

}
lcd_cmd(0xc0);
lcd_data( " HELLO World");
}
 

First please specify which LCD and its datasheet. then only we can identify the memory banks and its initialization procedure.
 

show the schematic of your lcd device ,,,,,,,,,,,,,,,,,, is der any decoders? or u hv connected directly from the controller ports
 

it seems you are using alphanumeric character LCD. issue initialisation command (0x38 ) 3-4 times with delays of 50msec between each command.
 

Code:
org 0h
mov r5,#3
mov a,#38h
acall command
mov a,#0eh
acall command
mov a,#01h
acall command
mov a,#06h
acall command
mov a,#86h
acall command

here1:
acall again
mov a,r2
acall display
djnz r5,here1

mov r5,#3
mov a,#0c6h
acall command
repeat:
acall again
mov a,r2
acall display
djnz r5,repeat



command: acall ready
mov p1,a
clr p2.0
clr p2.1
setb p2.2
clr p2.2
ret

display: acall ready
mov p1,a
setb p2.0
clr p2.1
setb p2.2
acall delay
clr p2.2
ret

ready: setb p1.7
clr p2.0
setb p2.1
back: clr p2.2
acall delay
setb p2.2
jb p1.7,back
ret

again:
mov p3,#00000111b
mov a,p3
anl a,#00000111b
cjne a,#00000111b,again
again1:
acall delay1
mov a,p3
anl a,#00000111b
cjne a,#00000111b,check
sjmp again1
check:
mov a,p3
anl a,#00000111b
cjne a,#00000111b,check1
sjmp again1
check1:
mov p3,#11110111b
mov a,p3
anl a,#11110111b
cjne a,#11110111b,row0

mov p3,#11101111b
mov a,p3
anl a,#11101111b
cjne a,#11101111b,row1

mov p3,#11011111b
mov a,p3
anl a,#11011111b
cjne a,#11011111b,row2

mov p3,#10111111b
mov a,p3
anl a,#10111111b
cjne a,#10111111b,row3

ljmp again1


row0:
mov dptr,#code0
sjmp find
row1:
mov dptr,#code1
sjmp find
row2:
mov dptr,#code2
sjmp find
row3:
mov dptr,#code3
sjmp find


find:
rrc a
jnc match
inc dptr
sjmp find

match:
clr a
movc a,@a+dptr
mov r2,a

delay: mov r3,#50
here:
mov r4,#255
here2:
djnz r4,here2
djnz r3,here
ret


delay1:
mov r0,#72
label:
mov r1,#255
label1:
djnz r1,label1
djnz r0,label
ret

org 300h

code0: db "1","2","3"
code1: db "4","5","6"
code2: db "7","8","9"
code3: db 2Ah,"0",23h



end

i hope it will help you
 

give some milli seconds delay between each command
the way you give data to lcd_data is wrong. check array example. command 01 will clear the screen so you wont see any data in lcd. after displaying data put a infinite loop.
 

give some milli seconds delay between each command
the way you give data to lcd_data is wrong. check array example. command 01 will clear the screen so you wont see any data in lcd. after displaying data put a infinite loop.


mov r5,#3
mov a,#0c6h
acall command
repeat:
acall again
mov a,r2
acall display
djnz r5,repeat
after this use sjmp $
it is working and i have confirmed it by simulating on proteus.. and its working..
i am just displaying 6 characters 3 in the above row and 3 in the below one
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top