;;晶体振荡f=12Mhz
TEN_BUF EQU 30H ;10秒 计数器
TWE_BUF EQU 31H ;20s
FIF_BUF EQU 32H ;50s
SENCOND EQU 40H ;s counter
;
TEN_LED REG P1.0 ;DISPLAY
TWE_LED REG P1.1
FIF_LED REG P1.2
;
TEN_KEY REG P1.4 ;KEY
TWE_KEY REG P1.5 ;INPUT
FIF_KEY REG P1.6
;
ORG 0000H
AJMP MAIN
ORG 0003H
RETI
ORG 000BH
AJMP TM_0
ORG 0013H
RETI
ORG 001BH
RETI
ORG 0023H
RETI
;
MAIN: MOV R0,#00H
DJNZ R0,$
MOV SP,#60H
MOV TEN_BUF,#10 ;10S
MOV TWE_BUF,#20 ;20S
MOV FIF_BUF,#50 ;50S
MOV P1,#FFH ;ALL LED CLOSE
CALL RDY_T
$0 JB TEN_KEY,$1
SETB TEN_LED ;关闭LED
MOV TEN_BUF,#10 ;10S
$A CALL DELAY
JNB TEN_KEY,$A ;等待按键放开
;
$1 JB TWE_KEY,$2
SETB TWE_LED
MOV TWE_BUF,#20 ;20S
$B CALL DELAY
JNB TEN_KEY,$B
;
$2 JB FIF_KEY,$0
SETB FIF_LED
MOV FIF_BUF,#50 ;50S
$C CALL DELAY
JNB TEN_KEY,$C
;
AJMP $0
;
;
;
RDY_T MOV TMOD,#11H
MOV TH0,#3CH
MOV TL0,#B0H
MOV SENCOND,#20
CLR TF0
SETB TR0
SETB ET0
SETB EA
RET
;
DELAY: MOV R7,#50
MOV R6,#00
$1 DJNZ R6,$1
DJNZ R7,$1
RET
;
TM_0: MOV TL0,#B0H ; TIMER 50 ms
MOV TH0,#3CH
DJNZ SENCOND,$0 ;50ms * 20 = 1S
MOV SENCOND,#20
MOV A,TEN_BUF
JZ $1 ;10 S 计时完毕
DJNZ TEN_BUF,$1
CLR TEN_LED ;10S 到时 LED 亮
;
$1 MOV A,TWE_BUF
JZ $2
DJNZ TWE_BUF,$2
CLR TWE_LED
;
$2 MOV A,FIF_BUF
JZ $0
DJNZ FIF_BUF,$0
CLR FIF_LED
$0 RETI
;;;;
大家看下 对不!!!