求大神看一下我写的这个程序
时间:10-02
整理:3721RD
点击:
在proteus仿真运行的时候,K2按键调节的时候不管用,我想问一下是我的程序那里有问题,看了很久,实在找不出啊!
K1 EQU P3.2
K2 EQU P3.3
TIME0 EQU 24H
TIME1 EQU 25H
SECOND EQU 28H
FLAG EQU 20H.1
FLAG1 EQU 20H.2
FLAG2 EQU 29H
ORG 0000H
AJMP MAIN
ORG 001BH
LJMP INT_T1
;******主程序******
ORG 0030H
MAIN: MOV SP,#60H
MOV TMOD,#10H
MOV TL1,#0E0H
MOV TH1,#0B1H
MOV TIME0,#00H
MOV TIME1,#01H
MOV SECOND,#00H
MOV FLAG2,#00H
MOV R0,#19H
SETB FLAG
SETB FLAG1
SETB TR1
SETB ET1
SETB EA
;******LED数码管显示子程序******
LEDDISPLAY:MOV DPTR,#TAB
SETB P3.1
LCALL DELAY
CLR P3.1
MOV A,TIME0
MOVC A,@A+DPTR
JB FLAG,L0
ANL A,#7FH
L0: MOV P1,A
SETB P3.0
LCALL DELAY
CLR P3.0
MOV A,TIME1
MOVC A,@A+DPTR
MOV P1,A
LCALL KEYJUDGE
LJMP LEDDISPLAY
;******T1中断程序******
INT_T1:MOV TL1,#0E0H
MOV TH1,#0B1H
DJNZ R0,TTT0
CPL FLAG
MOV R0,#19H
JNB FLAG,TTT0
LCALL TIMER
TTT0: RETI
;******倒计数子程序******
TIMER: INC SECOND
MOV A,SECOND
CJNE A,#3CH,TT0
CLR SECOND
MOV A,TIME1
CJNE A,#00H,TT1
MOV A,TIME0
CJNE A,#00H,TT2
CLR TR1
CLR P3.4
LJMP TT0
TT1: MOV A,TIME0
CJNE A,#00H,TT2
DEC TIME1
MOV TIME0,#09H
LJMP TT0
TT2: DEC TIME0
TT0: RET
;******按键判断子程序******
KEYJUDGE:JB K1,AK1
LCALL DELAY
LCALL DELAY
JNB K1,$
INC FLAG2
MOV B,#03H
MOV A,FLAG2
div AB
MOV A,B
CJNE A,#01H,AN2
CLR ET1
CLR TR1
LJMP AK2
AN2: CJNE A,#02H,AN3
CLR ET1
CLR TR1
LJMP AK2
AN3: CJNE A,#00H,AN4
SETB TR1
SETB ET1
LJMP AK2
AN4: CLR ET1
CLR TR1
LJMP AK2
AK1: JB K2,AK2
LCALL DELAY
LCALL DELAY
CJNE A,#01H,SETT1
LCALL SET_TIME0
LJMP AK2
SETT1: CJNE A,#02H,AK2
LCALL SET_TIME1
AK2: RET
;******定时时间个位设定子程序******
SET_TIME0:
INC TIME0
MOV A,TIME0
CJNE A,#09H,SET01
MOV TIME0,#00H
SET01: RET
;******定时时间十位设定子程序******
SET_TIME1:
INC TIME1
MOV A,TIME1
CJNE A,#09H,SET11
MOV TIME1,#00H
SET11: RET
;******延时子程序******
DELAY: MOV R7,#100
DJNZ R7,$
RET
;******数码管字形表******
TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH
END
K1 EQU P3.2
K2 EQU P3.3
TIME0 EQU 24H
TIME1 EQU 25H
SECOND EQU 28H
FLAG EQU 20H.1
FLAG1 EQU 20H.2
FLAG2 EQU 29H
ORG 0000H
AJMP MAIN
ORG 001BH
LJMP INT_T1
;******主程序******
ORG 0030H
MAIN: MOV SP,#60H
MOV TMOD,#10H
MOV TL1,#0E0H
MOV TH1,#0B1H
MOV TIME0,#00H
MOV TIME1,#01H
MOV SECOND,#00H
MOV FLAG2,#00H
MOV R0,#19H
SETB FLAG
SETB FLAG1
SETB TR1
SETB ET1
SETB EA
;******LED数码管显示子程序******
LEDDISPLAY:MOV DPTR,#TAB
SETB P3.1
LCALL DELAY
CLR P3.1
MOV A,TIME0
MOVC A,@A+DPTR
JB FLAG,L0
ANL A,#7FH
L0: MOV P1,A
SETB P3.0
LCALL DELAY
CLR P3.0
MOV A,TIME1
MOVC A,@A+DPTR
MOV P1,A
LCALL KEYJUDGE
LJMP LEDDISPLAY
;******T1中断程序******
INT_T1:MOV TL1,#0E0H
MOV TH1,#0B1H
DJNZ R0,TTT0
CPL FLAG
MOV R0,#19H
JNB FLAG,TTT0
LCALL TIMER
TTT0: RETI
;******倒计数子程序******
TIMER: INC SECOND
MOV A,SECOND
CJNE A,#3CH,TT0
CLR SECOND
MOV A,TIME1
CJNE A,#00H,TT1
MOV A,TIME0
CJNE A,#00H,TT2
CLR TR1
CLR P3.4
LJMP TT0
TT1: MOV A,TIME0
CJNE A,#00H,TT2
DEC TIME1
MOV TIME0,#09H
LJMP TT0
TT2: DEC TIME0
TT0: RET
;******按键判断子程序******
KEYJUDGE:JB K1,AK1
LCALL DELAY
LCALL DELAY
JNB K1,$
INC FLAG2
MOV B,#03H
MOV A,FLAG2
div AB
MOV A,B
CJNE A,#01H,AN2
CLR ET1
CLR TR1
LJMP AK2
AN2: CJNE A,#02H,AN3
CLR ET1
CLR TR1
LJMP AK2
AN3: CJNE A,#00H,AN4
SETB TR1
SETB ET1
LJMP AK2
AN4: CLR ET1
CLR TR1
LJMP AK2
AK1: JB K2,AK2
LCALL DELAY
LCALL DELAY
CJNE A,#01H,SETT1
LCALL SET_TIME0
LJMP AK2
SETT1: CJNE A,#02H,AK2
LCALL SET_TIME1
AK2: RET
;******定时时间个位设定子程序******
SET_TIME0:
INC TIME0
MOV A,TIME0
CJNE A,#09H,SET01
MOV TIME0,#00H
SET01: RET
;******定时时间十位设定子程序******
SET_TIME1:
INC TIME1
MOV A,TIME1
CJNE A,#09H,SET11
MOV TIME1,#00H
SET11: RET
;******延时子程序******
DELAY: MOV R7,#100
DJNZ R7,$
RET
;******数码管字形表******
TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH
END
好长哦