protues仿真时,为什么程序运行4秒后,再按键就没有反应了,求大家帮帮我,谢谢!(下面是我的程序)
时间:10-02
整理:3721RD
点击:
程序为按键显示,为使按键时数码管稳定显示,我设置定时器定时50ms显示一次。但是protues仿真时,为什么程序运行4秒后,再按键就没有反应了,求大家帮帮我,谢谢!(下面是我的程序)
ORG 0000H
AJMP MAIN
ORG 000BH
LJMP DISP
MAIN: MOV SP,#3FH
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
MOV 30H,#1
MOV 31H,#0
MOV 32H,#0
MOV 33H,#0
MOV 34H,#0
MOV 35H,#0
MOV 36H,#0
MOV 37H,#0
SETB ET0
SETB EA
SETB TR0
AGAIN: ACALL KEY
CJNE A,#0FFH,A1
AJMP AGAIN
A1: MOV 37H,36H
MOV 36H,35H
MOV 35H,34H
MOV 34H,33H
MOV 33H,32H
MOV 32H,31H
MOV 31H,30H
MOV 30H,A
AJMP AGAIN
DISP: MOV TH0,#3CH
MOV TL0,#0B0H
PUSH PSW
PUSH ACC
MOV R7,#8
MOV R0,#30H
MOV R1,#0
DSIP1: MOV A,@R0
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,#00H
MOV P0,A
MOV A,R1
RL A
RL A
MOV P2,A
ACALL DELAY
INC R0
INC R1
DJNZ R7,DSIP1
POP ACC
POP PSW
RETI
DELAY: MOV R5,#5
D1: MOV R4,#0
DJNZ R4,$
DJNZ R5,D1
RET
TAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH
DB 07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H
KEY: MOV B,#0FFH
MOV P1,#0F0H
MOV A,P1
ANL A,#0F0H
CJNE A,#0F0H,KEY1
AJMP KEY6
KEY1: ACALL DELAY
MOV P1,#0F0H
MOV A,P1
ANL A,#0F0H
CJNE A,0F0H,KEY2
AJMP KEY6
KEY2: MOV R7,#4
MOV B,#0
MOV R0,#0FEH
KEY3: MOV P1,R0
MOV A,P1
ANL A,#0F0H
CJNE A,#0F0H,KEY4
INC B
MOV A,R0
RL A
MOV R0,A
DJNZ R7,KEY3
KEY4: RLC A
JNC KEY5
INC B
INC B
INC B
INC B
SJMP KEY4
KEY5: MOV P1,#0F0H
MOV A,P1
ANL A,#0F0H
CJNE A,#0F0H,KEY5
KEY6: MOV A,B
RET
END
ORG 0000H
AJMP MAIN
ORG 000BH
LJMP DISP
MAIN: MOV SP,#3FH
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
MOV 30H,#1
MOV 31H,#0
MOV 32H,#0
MOV 33H,#0
MOV 34H,#0
MOV 35H,#0
MOV 36H,#0
MOV 37H,#0
SETB ET0
SETB EA
SETB TR0
AGAIN: ACALL KEY
CJNE A,#0FFH,A1
AJMP AGAIN
A1: MOV 37H,36H
MOV 36H,35H
MOV 35H,34H
MOV 34H,33H
MOV 33H,32H
MOV 32H,31H
MOV 31H,30H
MOV 30H,A
AJMP AGAIN
DISP: MOV TH0,#3CH
MOV TL0,#0B0H
PUSH PSW
PUSH ACC
MOV R7,#8
MOV R0,#30H
MOV R1,#0
DSIP1: MOV A,@R0
MOV DPTR,#TAB
MOVC A,@A+DPTR
MOV P0,#00H
MOV P0,A
MOV A,R1
RL A
RL A
MOV P2,A
ACALL DELAY
INC R0
INC R1
DJNZ R7,DSIP1
POP ACC
POP PSW
RETI
DELAY: MOV R5,#5
D1: MOV R4,#0
DJNZ R4,$
DJNZ R5,D1
RET
TAB: DB 3FH,06H,5BH,4FH,66H,6DH,7DH
DB 07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H
KEY: MOV B,#0FFH
MOV P1,#0F0H
MOV A,P1
ANL A,#0F0H
CJNE A,#0F0H,KEY1
AJMP KEY6
KEY1: ACALL DELAY
MOV P1,#0F0H
MOV A,P1
ANL A,#0F0H
CJNE A,0F0H,KEY2
AJMP KEY6
KEY2: MOV R7,#4
MOV B,#0
MOV R0,#0FEH
KEY3: MOV P1,R0
MOV A,P1
ANL A,#0F0H
CJNE A,#0F0H,KEY4
INC B
MOV A,R0
RL A
MOV R0,A
DJNZ R7,KEY3
KEY4: RLC A
JNC KEY5
INC B
INC B
INC B
INC B
SJMP KEY4
KEY5: MOV P1,#0F0H
MOV A,P1
ANL A,#0F0H
CJNE A,#0F0H,KEY5
KEY6: MOV A,B
RET
END