Documente Academic
Documente Profesional
Documente Cultură
c
This is special section of web-site. In this section we will learn how we can display a
character or a message on LCD display. You can choose any standard LCD available
in market. I have experimented with 20×2 LCD. It means LCD has 2 lines of 20
characters each. Many other LCDs like 16×2, 24×2, 32×2, 20×4 etc. are available.
Functionally all these LCDs are same. To develop a protocol to interface this LCD
with 89C51 first we have to understand how they functions.
These displays contains two internal byte-wide registers, one for command and
second for characters to be displayed. There are three control signals called R/W,
DI/RS and En. The table given below will tell you what is the use of these three
signals.
Dy making RS/DI signal 0 you can send different commands to display. These
commands are used to initialized LCD, to select display pattern, to shift cursor or
screen etc. The different commands and their functions are as given below
D
! " # $
0 0 0 0 0 0 0 0 0 1 Clear LCD memory, Home cursor
0 0 0 0 0 0 0 0 1 0 Clear and Home cursor only
s = 1/0 : Shift screen/cursor, I/O = 1/0 :
0 0 0 0 0 0 0 1 I/O s
shift R/L
D = 1/0 : Screen On/Off. C = 1/0 :
0 0 0 0 0 0 1 D C B cursor On/Off. B = 1/0 : Cursor blink/no
blink
S/C = 1/0 : Screen / Cursor. R/L = 1/0 :
0 0 0 0 0 1 S/C R/L 0 0
Shift one space right / left
D/L = 1/0 : 8/4 bits per character. N =
0 0 0 0 1 DL N F 0 0 1/0 : 2/1 rows of char. F = 1/0 :
5×10/5×7 dots/char.
0 0 0 1 Char address Write to char. RAM address after this
Writes to display RAM address after
0 0 1 Display data address
this
1 BF Current address BF = 1/0 : display is busy/not busy
1 0 Character type Write byte to last RAM chosen
1 1 Character type Read byte from last RAM chosen
6he figure shows connections of LCD with 89C51
Îll the data lines of LCD are connected with port P1. En pin is connected with P0.0,
DI (RS) is connected with P0.1 and R/W pin is connected with P0.2.
Next the program is given in 8051 assembly language with necessary comments that
can display a message or single character on screen.
org 00h
cmmd:
acall ready ; wait until display is busy
mov p1,a ; command chara. in p1
clr p0.1 ; select com. register
clr p0.2 ; write enable
setb p0.0 ; strobe the chara.
clr p0.0
ret
dis:
acall ready ; wait until display is busy
mov p1,a ; data chara. in p1
setb p0.1 ; select data register
clr p0.2 ; write enable
setb p3.7 ; strobe the chara.
clr p3.7
ret
ready:
mov r7,p0 ; save content of P0
clr p0.0 ; disable display
clr p0.1 ; select command register
setb p0.2 ; read enable
wait:clr p0.0 ; strobe display
setb p0.0 ; read busy status of display
jb p1.7,wait ; wait for busy
clr p3.7
mov p0,r7 ; restore content of P0
ret
org 3000h
db com
db 0c5h
db dat
db 'Program'
db eof
end