Department of Computer Scien
ce and Information Engineering
National Cheng Kung University, TAIWAN
8255 HANEL
INTERFACING
LCD
Connection To The 8255
(cont
;New command write subroutine with checking busy flagNCMDWRT:MOV R2,A ’)
;save a value
MOV A,#90H
;PA=IN to read LCD status
MOV R0,#CNTPORT ;load control reg addressMOVX @R0,A
;configure PA=IN, PB=OUT
MOV A,#00000110B ;RS=
0,R/W=1,E=1 read command
MOV R0,#BPORT ;load port B addressMOVX @R0,A ;RS=0,
R/W=1 for RD and RS pins
MOV R0,#APORT ;load port A address
READY: MOVX A,@R0
;read command reg
PLC A ;mo
ve D7(busy flag) into carry
JC READY
;wait until LCD is ready
MOV A,#80H ;m
ake PA and PB output again
MOV R0,#CNTPORT ;load control port addressMOVX @R0,A ;i
ssue control word to 8255
MOV A,R2
;get back value to LCD
MOV R0,#APORT ;load port A address MOVX @R0,A ;issue
info to LCD’s data pins
MOV R0,#BPORT ;load port B address MOV A,#00000100B ;RS=
0,R/W=0,E=1 for H-To-L
MOVX @R0,A ;activ
ate RS,R/W,E pins of LCD
NOP
;make E pin pulse wide enough
NOPMOV A,#00000000B ;RS=
0,R/W=0,E=0 for H-To-L
MOVX @R0,A ;latch
in LCD’s data pin info
RET
Program 15-2. (cont’)