ä¸ã
K1 EQU P1.0
K2 EQU P1.1
K3 EQU P1.2
K4 EQU P1.3
LED1 EQU P1.4
LED2 EQU P1.5
LED3 EQU P1.6
LED4 EQU P1.7
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
SETB ET0
SETB EA
SETB LED1
CLR LED2
SETB LED3
SETB LED4
CLR A
SJMP $
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
JB K1,T01
CLR LED1
SJMP T02
T01:
SETB LED1
T02:
JB K2,T03
SETB LED2
SJMP T04
T03:
CLR LED2
T04:
JB K3,T05
CPL LED3
SJMP T06
T05:
SETB LED3
T06:
JB K4,T07
INC A
CJNE A,#10,T08
CLR A
CPL LED4
SJMP T08
T07:
SETB LED4
T08:
RETI
END
äºã
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
SETB ET0
SETB EA
MOV B,#0EFH
MOV R3,#0
LOOP:
JB K1,LP1
JNB K1,$
MOV R2,#2
SETB TR0
SJMP LOOP
LP1:
JB K2,LP2
JNB K2,$
MOV R2,#3
SETB TR0
SJMP LOOP
LP2:
JB K3,LP3
JNB K3,$
MOV R2,#4
SETB TR0
SJMP LOOP
LP3:
JB K4,LOOP
JNB K4,$
MOV R2,#5
SETB TR0
SJMP LOOP
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
MOV A,B
ANL A,#0FH
MOV P1,A
RL A
MOV B,A
INC R3
CJNE R3,#4,T0E
MOV R3,#0
DEC R2
CJNE R2,#0,T0E
CLR TR0
T0E:
RETI
温馨提示:答案为网友推荐,仅供参考