Video Demo
Code
$MOD51
E BIT P3.2
RS BIT P3.1
RW BIT P3.0
ORG 00
MAIN:
LCALL SETUP
DONG2:
MOV DPTR,#DIS2
SETB E
CLR RS
CLR RW
MOV P1,#0C0H
CLR E
LCALL WAIT
LCALL XUAT_CHU
DONG1:
MOV DPTR,#DIS1
DICH:
LCALL DISPLAY1
LCALL DELEY
LCALL DELEY
INC DPTR
MOV A,DPL
CJNE A,#LOW(DIS1+40),DICH
MOV A,DPH
CJNE A,#HIGH(DIS1+40),DICH
SJMP DONG1
SETUP:
SETB E
CLR RS
CLR RW
MOV P1,#38H ;cai dat ban dau
CLR E
LCALL WAIT
SETB E
CLR RS
CLR RW
MOV P1,#0CH
CLR E
LCALL WAIT
SETB E
CLR RS
CLR RW
MOV P1,#06H
CLR E
LCALL WAIT
RET
DISPLAY1:
SETB E
CLR RS
CLR RW
MOV P1,#80H
CLR E
LCALL WAIT
XUAT_CHU:
MOV R1,#0
LOOP:
MOV A,R1
MOVC A,@A+DPTR
SETB E
SETB RS
CLR RW
MOV P1,A
CLR E
LCALL WAIT
INC R1
CJNE R1,#20,LOOP
RET
WAIT: ;thoi gian doi 1ms
MOV TMOD,#10H
MOV TH1,#HIGH(-1000)
MOV TL1,#LOW(-1000)
CLR TF1
SETB TR1
JNB TF1,$
CLR TR1
CLR TF1
RET
DELEY: ;thoi gian de lay 1s
MOV R0,#100
CONT:
MOV TMOD,#10H
MOV TH1,#HIGH(-10000)
MOV TL1,#LOW(-10000)
CLR TF1
SETB TR1
JNB TF1,$
CLR TR1
CLR TF1
DJNZ R0,CONT
RET
ORG 100H
DIS1:
DB 'DEMO GIAO TIEP 8051-LCD '
ORG 200H
DIS2:
DB 'BY:CHIPKOOL.TK'
END
Phạm Văn Ngọc Anh- 01644326695
Đăng nhận xét