Department of Computer Science and Information EngineeringNational Cheng Kung University, TAIWANLCD HANEL
INTERFACINGSending Data/ Commands to LCDs w/ TimeDelay(cont’)
.....
MOV A,#’N’ ;display letter NACALL DATAWRT ;call display subroutineACALL DELAY ;give LCD some timeMOV A,#’O’ ;display letter OACALL DATAWRT ;call display subroutine
AGAIN: SJMP AGAIN ;stay hereCOMNWRT:;send command to LCD
MOV P1,A ;copy reg A to port 1CLR P2.0 ;RS=0 for commandCLR P2.1 ;R/W=0 for writeSETB P2.2 ;E=1 for high pulseACALL DELAY ;give LCD some timeCLR P2.2 ;E=0 for H-to-L pulseRET
DATAWRT:;write data to LCDMOV P1,A ;copy reg A to port 1SETB P2.0 ;RS=1 for dataCLR P2.1 ;R/W=0 for writeSETB P2.2 ;E=1 for high pulseACALL DELAY ;give LCD some timeCLR P2.2 ;E=0 for H-to-L pulseRET
DELAY: MOV R3,#50 ;50 or higher for fast CPUsHERE2: MOV R4,#255 ;R4 = 255HERE: DJNZ R4,HERE;stay until R4 becomes 0DJNZ R3,HERE2RETEND8051 P1.0 P1.7 P2.0 P2.1 P2.2D0 D7 RS R/W EVCC VEE VSS10kPOT
LCD+5V