Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWAN8255 HANEL
INTERFACINGLCD
Connection To The 8255(cont
;New data write subroutine ’)
with checking busy flag
NDATAWRT:MOV R2,#A;save a valueMOV A,#90H ;PA=IN toread LCD status,PB=outMOV R0,#CNTPORT ;load control port addressMOVX @R0,A;configure PA=IN, PB=OUTMOV A,#00000110B ;RS=0,R/W=1,E=1 read commandMOV R0,#BPORT ;load port B addressMOVX @R0,A ;RS=0,R/W=1 for RD and RS pinsMOV R0,#APORT ;load port A address
READY: MOVX A,@R0;read command regPLC A ;move D7(busy flag) into carryJC READY;wait until LCD is readyMOV A,#80H ;make PA and PB output againMOV R0,#CNTPORT ;load control port addressMOVX @R0,A ;issue control word to 8255MOV A,R2;get back value to LCDMOV R0,#APORT ;load port A address MOVX @R0,A ;issueinfo to LCD’s data pinsMOV R0,#BPORT ;load port B address MOV A,#00000101B ;RS=1,R/W=0,E=1 for H-To-LMOVX @R0,A ;activate RS,R/W,E pins of LCDNOP;make E pin pulse wide enoughNOPMOV A,#00000001B ;RS=1,R/W=0,E=0 for H-To-LMOVX @R0,A ;latchin LCD’s data pin infoRET
Program 15-2. (cont’)