Hey we have got a problem in interfacing a 20*4 lcd to 89c51rd2.
It is displaying all garbage values. I am hereby attaching our simple lcd program. We have also verified the hardware connections.Can anybody pls help us in finding out the problem.
;LCD module
$mod51
P2 data 0a0h
lrs BIT P3.0
lrw BIT P3.1
len BIT P3.2
ORG 0000H
SJMP 0030H
ORG 0030H
MOV SP,#70H
name0:
lcall lcdisp ;go for LCD initialization
mov a,#84h ;set cursor to first line
lcall command
ACALL DELAY
mov dptr,#name1 ;data pointer for line 1 chars, 5th posn
mov r3,#0dh ;no. of characters
lcall disp0 ;display characters
mov a,#0c4h ;bring cursor to second line
lcall command
ACALL DELAY
mov dptr,#name2 ;data pointer for line 2 chars,5th posn
mov r3,#0ch ;no. of characters
lcall disp0 ;display characters
mov a,#99h ;set cursor to third line,5th posn
lcall command
ACALL DELAY
mov dptr,#name3 ;data pointer for line 3 chars.
mov r3,#0ah ;no. of characters
lcall disp0 ;display characters
here: sjmp here ;Wait in infinite loop
;INITIALIZATION MODULE
disp0: clr a ;offset cleared every time
movc a,@a+dptr ;mov character to be displayed into acc.
lcall display ;call routine to display single char.
acall delay
inc dptr ;increament pointer to next char.
djnz r3,disp0 ;check for no. of chars.
ret
;MODULE FOR DISPLAY OF SINGLE CHARACTER
delay:mov 10h,#50
here2:mov 11h,#255
here1: djnz 11h,here1
djnz 10h,here2
ret
;INITIALIZATION MODULE
lcdisp: MOV A,#38H ;init. lcd 4 lines p1,5x7 matrix
acall COMMAND
acall delay ;issue command
MOV A,#0eH ;lcd on,curser off
ACALL COMMAND
acall delay ;issue command
MOV A,#01H ;lcd on,curser off
ACALL COMMAND
acall delay ;issue command
MOV A,#06H ;clear lcd command
ACALL COMMAND ;issue command
ACALL DELAY
RET
COMMAND: MOV P2,A ;issue command code
CLR lRS
CLR lRW
SETB lEn
acall delay
CLR lEn
RET
display:mov P2,a
setb lrs
clr lrw
setb len
ACALL DELAY
clr len
ret
org 3000h
name1: db "SOLDERABILITY",0
name2: db "TESTING UNIT",0
name3: db "CONTROLLER",0
end
It is displaying all garbage values. I am hereby attaching our simple lcd program. We have also verified the hardware connections.Can anybody pls help us in finding out the problem.
;LCD module
$mod51
P2 data 0a0h
lrs BIT P3.0
lrw BIT P3.1
len BIT P3.2
ORG 0000H
SJMP 0030H
ORG 0030H
MOV SP,#70H
name0:
lcall lcdisp ;go for LCD initialization
mov a,#84h ;set cursor to first line
lcall command
ACALL DELAY
mov dptr,#name1 ;data pointer for line 1 chars, 5th posn
mov r3,#0dh ;no. of characters
lcall disp0 ;display characters
mov a,#0c4h ;bring cursor to second line
lcall command
ACALL DELAY
mov dptr,#name2 ;data pointer for line 2 chars,5th posn
mov r3,#0ch ;no. of characters
lcall disp0 ;display characters
mov a,#99h ;set cursor to third line,5th posn
lcall command
ACALL DELAY
mov dptr,#name3 ;data pointer for line 3 chars.
mov r3,#0ah ;no. of characters
lcall disp0 ;display characters
here: sjmp here ;Wait in infinite loop
;INITIALIZATION MODULE
disp0: clr a ;offset cleared every time
movc a,@a+dptr ;mov character to be displayed into acc.
lcall display ;call routine to display single char.
acall delay
inc dptr ;increament pointer to next char.
djnz r3,disp0 ;check for no. of chars.
ret
;MODULE FOR DISPLAY OF SINGLE CHARACTER
delay:mov 10h,#50
here2:mov 11h,#255
here1: djnz 11h,here1
djnz 10h,here2
ret
;INITIALIZATION MODULE
lcdisp: MOV A,#38H ;init. lcd 4 lines p1,5x7 matrix
acall COMMAND
acall delay ;issue command
MOV A,#0eH ;lcd on,curser off
ACALL COMMAND
acall delay ;issue command
MOV A,#01H ;lcd on,curser off
ACALL COMMAND
acall delay ;issue command
MOV A,#06H ;clear lcd command
ACALL COMMAND ;issue command
ACALL DELAY
RET
COMMAND: MOV P2,A ;issue command code
CLR lRS
CLR lRW
SETB lEn
acall delay
CLR lEn
RET
display:mov P2,a
setb lrs
clr lrw
setb len
ACALL DELAY
clr len
ret
org 3000h
name1: db "SOLDERABILITY",0
name2: db "TESTING UNIT",0
name3: db "CONTROLLER",0
end