Hi, im new to 8951. I am interfacing a LCD to a 8951, however it doesnt seems to work...can anyone help me check my program?
im using 11.059Mhz crystal and 30pF cap.
thank you vry much!!!
im using 11.059Mhz crystal and 30pF cap.
Code:
Here Data pins D0-D7 are connected to port1.0-port1.7 of 8951 microcontroller.
Enable pin, RS are connected to P3.3 and P3.4 of 8951 respectively.
R/W is connected to p3.5
ORG 0H
mOV TmOD,#20H ;Timer 1 in mode 2
mOV TH1,#-3 ;9600 baud rate
SETB TR1 ;Start timer 1
mOV SCON,#50H ;8-bit, 1 stop bit, REN enabled
MOV A,#38H ; initialization LCD 2lines, 5x7 matrix.
ACALL COMMAND ; call command subroutine.
MOV A,#0EH ; display on, cursor on
ACALL COMMAND
MOV A,#01H ; Clear LCD
ACALL COMMAND
MOV A,#06H ; shift cursor right
ACALL COMMAND
MOV A,#80H ; cursor at beginning of 1st line
ACALL COMMAND
MOV A,#'E' ; display letter E
ACALL DATA
MOV A,#'D' ; display letter D
ACALL DATA
MOV A,#' ' ; display space
ACALL DATA
MOV A,#'T' ; display letter T
ACALL DATA
MOV A,#'E' ; display letter E
ACALL DATA
MOV A,#'S' ; display letter S
ACALL DATA
MOV A,#'T' ; display letter T
HERE: JMP HERE
COMMAND: CALL READY ; check whether LCD is ready
MOV P1,A ; Send command to LCD
CLR P3.4 ; RS=0 for command
CLR P3.5 ; R/W=0 for write
SETB P3.3 ; E=1 for high pulse
CLR P3.3 ; E=0 for H-to-L pulse
RET
DATA: CALL READY ; check whether LCD is ready
MOV P1,A ; Write data to LCD
SETB P3.4 ; RS=1 for data
CLR P3.5 ; R/W=0 for write
SETB P3.3 ; E=1 for high pulse
CLR P3.3 ; E=0 for H-to-L pulse
RET
READY: SETB P1.7 ; make P1.7 input port
CLR P3.4 ; RS=0
SETB P3.5 ; R/W=1 for read
UP: SETB P3.3 ; E=1 for high pulse
CLR P3.3 ; E=0 for H-to-L pulse
JB P1.7, UP ; stay until LCD is busy
RET
thank you vry much!!!
Last edited: