小弟 刚开始学习1602 有很多不懂得地方。从网上下载了 一个汇编程序,做实际测试,发现不能够正常显示,不知道是什么原因。液晶显示屏只亮第二排,而且没有任何输出的信息。
以下是我用到的 程序 , 希望各位高手能帮我解决疑惑,,感激不尽......
;/////引脚定义/////
LCD_RS EQU P2.5
LCD_RW EQU P2.6
LCD_EN EQU P2.7
;/////主程序//////
ORG 0000H
AJMP MAIN
ORG 0030H
MAIN:
MOV SP,#60H
ACALL LCD_INIT
MAIN1:
ACALL CLR_LCD
MOV A,#80H
ACALL LCD_CMD
MOV DPTR,#LINE1
ACALL WRITE
MOV A,#0C0H
ACALL LCD_CMD
MOV DPTR,#LINE2
ACALL WRITE
LINE1: DB ' I KNOW I CAN ! ',00H
LINE2: DB " YOU ARE GREAT !",00H
;///////LCD 初始化///////
LCD_INIT:
ACALL DELAY5MS
ACALL DELAY5MS
ACALL DELAY5MS
MOV A,#38H
ACALL LCD_CMD_NC
ACALL DELAY5MS
MOV A,#38H
ACALL LCD_CMD_NC
ACALL DELAY5MS
MOV A,#38H
ACALL LCD_CMD_NC
ACALL DELAY5MS
MOV A,#08H
ACALL LCD_CMD
MOV A,#01H
ACALL LCD_CMD
MOV A,#0CH
ACALL LCD_CMD
RET
;////////清屏幕
CLR_LCD:
MOV A,#01H
ACALL LCD_CMD
RET
;///////进行忙检测
LCD_CMD:
CALL CHECKBUSY
;//////不进行忙检测
LCD_CMD_NC:
CLR LCD_RS
CLR LCD_RW
MOV P0,A
SETB LCD_EN
NOP
;NOP
;NOP
;NOP
CLR LCD_EN
RET
;/////忙检测
CHECKBUSY:
PUSH ACC
MOV P0,#0FFH
CLR LCD_RS
SETB LCD_RW
SETB LCD_EN
BUSYLOOP:
NOP
JB P0.7,BUSYLOOP
CLR LCD_EN
POP ACC
RET
;///////发送字符串
WRITE:
PUSH ACC
WRITE1:
CLR A
MOVC A,@A+DPTR
JZ WRITE2
INC DPTR
ACALL LCD_WDATA
JMP WRITE1
WRITE2:
POP ACC
RET
;////////写显示数据到LCD
LCD_WDATA:
ACALL CHECKBUSY
SETB LCD_RS
SETB LCD_RW
MOV P0,A
SETB LCD_EN
NOP
;NOP
;NOP
;NOP
CLR LCD_EN
RET
;//////
DELAY5MS:
MOV R6,#10
DL1:MOV R7,#249
DL2:DJNZ R7,DL2
DJNZ R6,DL1
RET
END |