|
$MOD52
RS EQU P1.0
RW EQU P1.1
E EQU P1.2
ORG 0000H
MAIN: MOV R0,#0
DJNZ R0,$
MOV SP,#60H
;
CALL SETTING ;初始化
MOV A,#0C0H ;选择显示位置
CALL CHECK_BUSY
CALL WRITE ;发送指令
MOV A,#'A' ;显示数据
CALL WRITE_DDR ;发送数据
JMP $
;
SETTING: MOV R1,#3 ;wait 15ms
LOOP3: CALL DELAY
DJNZ R1,LOOP3
MOV A,#00111000B ;***1***function set
CALL WRITE
;
CALL DELAY ;wait 4.1ms
;
MOV A,#00111000B ;***2***function set
CALL WRITE
;
MOV R1,#50 ;wait 100us
DJNZ R1,$
;
MOV A,#00111000B ;***3***function set
CALL WRITE
;
MOV A,#00111000B ;***4***function set
CALL CHECK_BUSY
CALL WRITE
;
MOV A,#00001000B ;***5***display off
CALL CHECK_BUSY
CALL WRITE
;
MOV A,#00000001B ;***6***display clear
CALL CHECK_BUSY
CALL WRITE
;
MOV A,#00000110B ;***7***光标移动是设置
CALL CHECK_BUSY
CALL WRITE
;
MOV A,#00001110B ;***8***显示设置
CALL CHECK_BUSY
CALL WRITE
;
RET
;
WRITE: CLR RS ;不检查忙指令写入
CLR RW
MOV P0,A
SETB E
NOP
CLR E
RET
;
WRITE_DDR: CALL CHECK_BUSY ;数据写入
SETB RS
CLR RW
MOV P0,A
SETB E
NOP
CLR E
RET
;
CHECK_BUSY: MOV P0,#0FFH ;检查忙指令
CLR RS
SETB RW
SETB E
LOOP1: JB P0.7,LOOP1
CLR E
CALL DELAY
RET
;
DELAY: MOV R0,#10 ;wait 5ms
DEL: MOV R2,#248
DJNZ R2,$
DJNZ R0,DEL
RET
;
END
;
;
先显示了,可是马上又变成一个乱的图案,之后就光标乱跳,那位大虾看看,指点下,不胜感激~~~
|
|