LCD_DATA EQU P2
TEMP_D EQU 30H
SBIT RS = P2^0
SBIT RW = P2^1
SBIT EN = P2^2
ORG 0
JMP MAIN
WRTCMD4 MACRO THAMSO
MOV TEMP_D,#THAMSO
MOV A,TEMP_D
ANL A,#0F0H
MOV LCD_DATA,A
CLR RS
CLR RW
SETB EN
CLR EN
CALL DELAY10MS
MOV A,TEMP_D
SWAP A
ANL A,#0F0H
MOV LCD_DATA,A
CLR RS
CLR RW
SETB EN
CLR EN
CALL DELAY10MS
ENDM
WRTDATA4:
MOV A,TEMP_D
ANL A,#0F0H
MOV LCD_DATA,A
SETB RS
CLR RW
SETB EN
CLR EN
CALL DELAY10MS
MOV A,TEMP_D
SWAP A
ANL A,#0F0H
MOV LCD_DATA,A
SETB RS
CLR RW
SETB EN
CLR EN
CALL DELAY10MS
RET
MAIN:
CLR EN
CALL DELAY200MS
MOV TEMP_D,#20H
ANL TEMP_D,#0F0H
MOV LCD_DATA,TEMP_D
CLR RS
CLR RW
SETB EN
CLR EN
CALL DELAY200MS
WRTCMD4 28H
WRTCMD4 01H
WRTCMD4 0CH
WRTCMD4 06H
WRTCMD4 83H
; WRTIE DATA - CHARACTER
MOV R0,#0
LAPA:
MOV A,R0
MOV DPTR,#MALCD
MOVC A,@A+DPTR
MOV TEMP_D,A
CALL WRTDATA4
INC R0
CJNE R0,#12,LAPA
DONG2: WRTCMD4 0C3H
MOV R7,#0
REW: MOV A,R7
MOV DPTR,#MALCD2
MOVC A,@A+DPTR
MOV TEMP_D,A
CALL WRTDATA4
INC R7
CJNE R7,#10,REW
IDLE: WRTCMD4 18H
CALL DELAY600MS
WRTCMD4 18H
CALL DELAY600MS
WRTCMD4 18H
CALL DELAY600MS
WRTCMD4 1CH
CALL DELAY600MS
WRTCMD4 1CH
CALL DELAY600MS
WRTCMD4 1CH
CALL DELAY600MS
JMP IDLE
DELAY10MS:
MOV R2,#20
LAP1: MOV R3,#100
LAP2: NOP
NOP
NOP
DJNZ R3,LAP2
DJNZ R2,LAP1
RET
DELAY200MS:
MOV R4,#20
LAP3: CALL DELAY10MS
DJNZ R4,LAP3
RET
DELAY600MS:
MOV R6,#3
LAP4: CALL DELAY200MS
DJNZ R6,LAP4
RET
MALCD: DB 'KHANH DUY BG'
MALCD2: DB 'DH KTCN TN'
END
https://www.youtube.com/watch?v=LsRpkZwaHcE
0 nhận xét:
Đăng nhận xét