kiranmayik
Newbie level 4
lcd_send_command( hd44780
hi everyone,
i tried interfacing at89c51 with 20X2 lcd display(ODM-20216S).
i have connected port1 to LCD and P3.0 to RS, P3.1 to R/W, P3.2 to E.
but the LCD is not showing any output.
this is the code:
;communicating with lcd
;checking busy flag before sending data, command to lcd
; P1= data pin, P3.0=RS, P3.1=R/W, P3.2=E pins
ORG 0H
MOV A,#38H ;initialize lcd 2 lines
ACALL COMMAND ;issue command
MOV A,#0EH ;lcd on, cursor on
ACALL COMMAND
MOV A,#02H ;return home
ACALL COMMAND
MOV A,#01H ;clear lcd command
ACALL COMMAND
MOV A,#06H ;shift cursor right
ACALL COMMAND
MOV A,#80H ;cursor:line 1,position 0
ACALL COMMAND
MOV A,#'L' ;display letter L
ACALL DATADISP
MOV A,#'C'
ACALL DATADISP
MOV A,#'D'
ACALL DATADISP
HERE:
SJMP HERE ;stay here
COMMAND:
ACALL READY ;check if lcd ready
MOV P1,A ;issue command code
CLR P3.0 ;RS=0 for command
CLR P3.1 ;R/W=0 to write to lcd
SETB P3.2 ;E=1 for H-to-L pulse
ACALL DELAY
CLR P3.2 ;E=0, latch in
RET
DATADISP:
ACALL READY ;check if lcd ready
MOV P1,A ;issue data
SETB P3.0 ;RS=1 for data
CLR P3.1 ; R/W=0 to write to lcd
SETB P3.2 ;E=1 for H-to-L pulse
ACALL DELAY ;give lcd some time
CLR P3.2 ;E=0, latch in
RET
READY:
SETB P1.7 ;make P1.7 input port
CLR P3.0 ;RS=0 access commang register
SETB P3.1 ;R/W=1 read command register
;read command register and check busy flag
BACK:
CLR P3.2 ;E=0 for L-to-H pulse
ACALL DELAY ;give lcd some time
SETB P3.2 ;E=1 L-to-H pulse
JB P1.7,BACK ;stay until busy flag=0
RET
DELAY:
MOV R3,#50
HERE1: MOV R4,#255
HERE2: DJNZ R4,HERE2
DJNZ R3,HERE1
RET
END
i'm not sure how much delays to give.do i have to give delay at the starting for power on.if so how much?and approximately how much delay is required for the enable pin.
please help.
thank you.
hi everyone,
i tried interfacing at89c51 with 20X2 lcd display(ODM-20216S).
i have connected port1 to LCD and P3.0 to RS, P3.1 to R/W, P3.2 to E.
but the LCD is not showing any output.
this is the code:
;communicating with lcd
;checking busy flag before sending data, command to lcd
; P1= data pin, P3.0=RS, P3.1=R/W, P3.2=E pins
ORG 0H
MOV A,#38H ;initialize lcd 2 lines
ACALL COMMAND ;issue command
MOV A,#0EH ;lcd on, cursor on
ACALL COMMAND
MOV A,#02H ;return home
ACALL COMMAND
MOV A,#01H ;clear lcd command
ACALL COMMAND
MOV A,#06H ;shift cursor right
ACALL COMMAND
MOV A,#80H ;cursor:line 1,position 0
ACALL COMMAND
MOV A,#'L' ;display letter L
ACALL DATADISP
MOV A,#'C'
ACALL DATADISP
MOV A,#'D'
ACALL DATADISP
HERE:
SJMP HERE ;stay here
COMMAND:
ACALL READY ;check if lcd ready
MOV P1,A ;issue command code
CLR P3.0 ;RS=0 for command
CLR P3.1 ;R/W=0 to write to lcd
SETB P3.2 ;E=1 for H-to-L pulse
ACALL DELAY
CLR P3.2 ;E=0, latch in
RET
DATADISP:
ACALL READY ;check if lcd ready
MOV P1,A ;issue data
SETB P3.0 ;RS=1 for data
CLR P3.1 ; R/W=0 to write to lcd
SETB P3.2 ;E=1 for H-to-L pulse
ACALL DELAY ;give lcd some time
CLR P3.2 ;E=0, latch in
RET
READY:
SETB P1.7 ;make P1.7 input port
CLR P3.0 ;RS=0 access commang register
SETB P3.1 ;R/W=1 read command register
;read command register and check busy flag
BACK:
CLR P3.2 ;E=0 for L-to-H pulse
ACALL DELAY ;give lcd some time
SETB P3.2 ;E=1 L-to-H pulse
JB P1.7,BACK ;stay until busy flag=0
RET
DELAY:
MOV R3,#50
HERE1: MOV R4,#255
HERE2: DJNZ R4,HERE2
DJNZ R3,HERE1
RET
END
i'm not sure how much delays to give.do i have to give delay at the starting for power on.if so how much?and approximately how much delay is required for the enable pin.
please help.
thank you.