SECOND EQU 30H ;定义计数储存单元
MBUF EQU 31H ;定义分计数储存单元
HBUF EQU 32H ;定义时计数储存单元
MBUF0 EQU 33H ;定义分个位计数储存单元
MBUF1 EQU 34H ;定义分十位计数储存单元
HBUF0 EQU 35H ;定义时个位计数储存单元
HBUF1 EQU 36H ;定义时十位计数储存单元
DP BIT 24H.3
ORG 0000H
JMP MAIN
ORG 0003H
JMP EXT0
ORG 000BH
JMP TIMER0
MAIN: MOV SP,#6FH
MOV TMOD,#01H
MOV TL0,#LOW(-62500)
MOV TH0,#HIGH(-62500)
MOV R2,#16
MOV IE,#10000010B
MOV IP,#00000010B
SETB TR0
MOV SECOND,#3CH ;60S
MOV MBUF0,#0 ;
MOV MBUF1,#0 ;
MOV HBUF0,#4
MOV HBUF1,#1
MOV MBUF,#00H
MOV HBUF,#14H
CALL LOOP
EXT0: NOP
SETB P1.3
CALL DISP
JMP EXT0
;***********************************************
LOOP: CALL DISP ;这个子程序怎么加进去? 可以用来用按键调整时间
JNB P3.3,MT
JNB P3.4,HT
AJMP LOOP
MT: CALL DISP
JNB P3.3,MT
INC MBUF0
MOV A,MBUF0
CJNE A,#10,LOOP
MOV MBUF0,#0
INC MBUF1
MOV A,MBUF1
CJNE A,#2,LOOP
MOV MBUF1,#0
JMP LOOP
HT: CALL DISP
JNB P3.4,HT
INC HBUF0
MOV A,HBUF0
CJNE A,#10,LOOP
MOV HBUF0,#0
INC HBUF1
MOV A,HBUF1
CJNE A,# 3,LOOP
MOV HBUF1,#0
AJMP LOOP
;*****************************************
TIMER0:PUSH ACC
MOV TL0,#LOW(-62500)
MOV TH0,#HIGH(-62500)
DJNZ R2,INT03
MOV R2,#16
CALL BEEP
CPL DP
DJNZ SECOND ,OUTT0
MOV SECOND,#60
ACALL ADD1
AJMP OUTT0
INT03: MOV A,R2
CJNE A,#8,OUTT0
CPL DP
OUTT0: POP ACC
RETI
ADD1: MOV A,MBUF
ADD A,#01
DA A
MOV MBUF,A
CJNE A,#60H,ADD13
MOV MBUF0,#0
MOV MBUF1,#0
MOV MBUF,#0
MOV A,HBUF
ADD A,#01
DA A
MOV HBUF,A
ADD13: MOV A,MBUF
ANL A,#0FH
MOV MBUF0,A
MOV A,MBUF
SWAP A
ANL A,#0FH
MOV MBUF1,A
MOV A,HBUF
CJNE A,#24,ADD14
MOV HBUF0,#0
MOV HBUF1,#0
MOV HBUF,#0
ADD14: MOV A,HBUF
ANL A,#0FH
MOV HBUF0,A
MOV A,HBUF
SWAP A
ANL A,#0FH
MOV HBUF1,A
RET
DSPM0: MOVC A,@A+DPTR
SETB C
MOV ACC.7,C
MOV P0,A
CLR P1.4
ACALL DY1MS
SETB P1.4
DM01: ACALL DY1MS
RET
DSPM1: MOVC A,@A+DPTR
MOV C,DP
MOV ACC.7,C
mov p0,A
CLR P1.5
CALL DY1MS
SETB P1.5
DM11: CALL DY1MS
RET
DSPH0: MOVC A,@A+DPTR
MOV C,DP
MOV ACC.7,C
MOV P0,A
CLR P1.6
CALL DY1MS
SETB P1.6
DH01: CALL DY1MS
RET
DSPH1: MOVC A,@A+DPTR
SETB C
MOV ACC.7,C
MOV P0,A
CLR P1.7
CALL DY1MS
SETB P1.7
DH11: ACALL DY1MS
RET
DISP:
MOV DPTR,#TAB2
MOV A,MBUF0
CALL DSPM0
MOV DPTR,#TAB2
MOV A,MBUF1
CALL DSPM1
MOV DPTR,#TAB1
MOV A,HBUF0
CALL DSPH0
MOV DPTR,#TAB1
MOV A,HBUF1
ANL A,#0FFH
JNZ DISP1
MOV A,#0AH
DISP1: CALL DSPH1
RET
BEEP: CLR P3.2
MOV 66H,250
DJNZ 66H,$
SETB P3.2
RET
DY1MS: MOV 67H,#2
DY1M1: MOV 68H,#250
DJNZ 68h,$
DJNZ 67H,DY1M1
RET
TAB1: DB 0C0H,0F9H,0A4H,0B0H
DB 99H,92H,82H,0F8H
DB 80H, 90H, 0FFH
TAB2: DB 0C0H,0CFH,0A4H,86H,08BH,92H,90H,0C7H,80H,82H,0FFH ;CPL ZC
END
用户216291 2009-8-31 10:40
用户158195 2009-8-15 10:28