MẠCH NGUYÊN LÝ
MẠCH IN
CODE LẬP TRÌNH
ORG 00H;Designer By ChipKool - SV UNETI - DTK3
KEY0:;khi nhan nut 0
JNB P3.0,KEY0OK;thuc hien nut 0
SJMP KEY1;khong nhan nut 0 thuc hien nut 1
KEY0OK:
CALL CTA;chuong trinh led sang chay
KEY1:;khi nhan nut 1
JNB P3.1,KEY1OK;thuc hien nut 1
SJMP KEY2;khong nhan nut 1 thuc hien nut 2
KEY1OK:
CALL CTB;chuong trinh led 2
KEY2:;khi nhan nut 2
JNB P3.2,KEY2OK
SJMP KEY3
KEY2OK:
CALL CTC
KEY3:;khi nhan nut 3
JNB P3.3,KEY3OK
SJMP KEY4
KEY3OK:
CALL CTD
KEY4:;khi nhan nut 4
JNB P3.4,KEY4OK
SJMP KEY5
KEY4OK:
CALL CTE
KEY5:;khi nhan nut 5
JNB P3.5,KEY5OK
SJMP KEY6
KEY5OK:
CALL CTF
KEY6:;khi nhan nut 6
JNB P3.6,KEY6OK
SJMP KEY7
KEY6OK:
CALL CTG
KEY7:;khi nhan nut 7
JNB P3.7,KEY7OK
SJMP KEY0;khong nhan nut 7 quay vong nut 0
KEY7OK:
CALL CTH
LJMP MAIN;nhay lai vong lap
CTA:;chuong trinh led sang chay
MOV P0,#00H
CALL DELAY
MOV P2,#00H
CALL DELAY
MOV R2,#2
CHIP:
MOV A,#10000000B
LAP1:
MOV P2,A
MOV P0,A
RR A
CALL DELAY
CJNE A,#10000000B,LAP1
DJNZ R2,CHIP
RET
CTB:
MOV A,#00H
LAP2:
SETB C
RRC A
MOV P2,A
MOV P0,A
CALL DELAY
CJNE A,#0FFH,LAP2
MOV A,#0FFH
LAP3:
CLR C
RRC A
MOV P2,A
MOV P0,A
CALL DELAY
CJNE A,#00H,LAP3
RET
CTC:
MOV R2,#3
CHIP2:
MOV A,#10000000B
LAP4:
MOV P2,A
MOV P0,A
RR A
CALL DELAY
CJNE A,#10000000B,LAP4
MOV A,#00000001B
LAP5:
MOV P2,A
MOV P0,A
RL A
CALL DELAY
CJNE A,#00000001B,LAP5
DJNZ R2,CHIP2
RET
CTD:
MOV R2,#2
CHIP4:
MOV A,#00H
LAP6:
SETB C
RRC A
MOV P2,A
MOV P0,A
CALL DELAY
CJNE A,#0FFH,LAP6
MOV A,#0FFH
LAP7:
CLR C
RLC A
MOV P2,A
MOV P0,A
CALL DELAY
CJNE A,#00H,LAP7
DJNZ R2,CHIP4
RET
CTE:
CALL QUAY
MOV P0,#00000001B
MOV P2,#00000001B
CALL DELAY
CALL QUAY
MOV P0,#00000011B
MOV P2,#00000011B
CALL DELAY
CALL QUAY
MOV P0,#00000111B
MOV P2,#00000111B
CALL DELAY
CALL QUAY
MOV P0,#00001111B
MOV P2,#00001111B
CALL DELAY
CALL QUAY
MOV P0,#00011111B
MOV P2,#00011111B
CALL DELAY
CALL QUAY
MOV P0,#00111111B
MOV P2,#00111111B
CALL DELAY
CALL QUAY
MOV P0,#01111111B
MOV P2,#01111111B
CALL DELAY
CALL QUAY
MOV P0,#11111111B
MOV P2,#11111111B
CALL DELAY
RET
QUAY:
MOV A,#10000000B
LAP20:
RR A
MOV P0,A
MOV P2,A
CALL DELAY
CJNE A,#10000000B,LAP20
RET
CTF:
MOV R5,#5
CHIP5:
MOV P2,#00H
MOV P0,#0FFH
CALL DELAY
MOV P0,#00H
MOV P2,#0FFH
CALL DELAY
DJNZ R5,CHIP5
RET
CTG:
MOV R2,#3
CHIP6:
MOV A,#01111111B
LAP9:
MOV P2,A
MOV P0,A
RR A
CALL DELAY
CJNE A,#01111111B,LAP9
DJNZ R2,CHIP6
RET
CTH:
MOV A,#10000000B
LAP21:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP21
MOV P2,#00000001B
MOV A,#10000000B
LAP22:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP22
MOV P2,#00000011B
MOV A,#10000000B
LAP23:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP23
MOV P2,#00000011B
MOV A,#10000000B
LAP24:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP24
MOV P2,#00000111B
MOV A,#10000000B
LAP25:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP25
MOV P2,#00001111B
MOV A,#10000000B
LAP26:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP26
MOV P2,#00011111B
MOV A,#10000000B
LAP27:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP27
MOV P2,#00111111B
MOV A,#10000000B
LAP28:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP28
MOV P2,#01111111B
MOV A,#10000000B
LAP29:
RR A
MOV P0,A
CALL DELAY
CJNE A,#10000000B,LAP29
MOV P2,#11111111B
RET
DELAY:;chuong trinh tao tre 0.04s
MOV R0,#200
LOOP1:
MOV R1,#200
LOOP2:
NOP
NOP
DJNZ R1,LOOP2
DJNZ R0,LOOP1
RET
END
Video
Phạm Văn Ngọc Anh- 01644326695
Đăng nhận xét