- HOUR EQU 32H
- MIN EQU 33H
- SEC EQU 34H
- TCN EQU 35H
- KEY_HOUR BIT P1.1
- KEY_MIN BIT P1.2
- KEY_SEC BIT P1.3
- ORG 0000H
- AJMP START
- ORG 000BH
- AJMP INT_T0
- ORG 0100H
- START:
- MOV DPTR,#SETTAB
- MOV TCN,#20
- MOV SP,#5FH
- MOV HOUR,#0
- MOV MIN,#0
- MOV SEC,#0
- MOV TMOD,01H
- MOV TH0,#3CH
- MOV TL0,0B0H
- SETB EA
- SETB ET0
- SETB TR0
- A1:LCALL DISP
- JNB KEY_HOUR,S1
- JNB KEY_MIN,S2
- JNB KEY_SEC,S3
- AJMP A1
- S1:LCALL DELAY
- JB KEY_HOUR,A1
- D1:INC HOUR
- MOV A,HOUR
- CJNE A,#24,J1
- MOV HOUR,#0
- J1:AJMP A1
- S2:LCALL DELAY
- JB KEY_MIN,A1
- D2:INC MIN
- MOV A,MIN
- CJNE A,#60,J2
- MOV MIN,#0
- AJMP D1
- J2:AJMP A1
- S3:LCALL DELAY
- JB KEY_SEC,A1
- INC SEC
- MOV A,SEC
- CJNE A,#60,J3
- MOV SEC,#0
- AJMP D2
- J3:
- AJMP A1
- INT_T0:PUSH PSW
- PUSH ACC
- MOV TH0,3CH
- MOV TL0,0B0H
- DEC TCN
- DJNZ TCN,OUT
- MOV TCN,#20
- INC SEC
- MOV A,SEC
- CJNE A,#60,OUT
- MOV SEC,#0
- INC MIN
- MOV A,MIN
- CJNE A,#60,OUT
- MOV MIN,#0
- INC HOUR
- MOV A,HOUR
- CJNE A,#24,OUT
- MOV HOUR,0
- OUT:POP ACC
- POP PSW
- RETI
- DISP: MOV P3,#0
- MOV A,SEC
- MOV B,#10
- DIV AB
- SETB P3.1
- MOVc A,@A+DPTR
- MOV P0,A
- LCALL DELAY
- MOV A,B
- CLR P3.1
- SETB P3.0
- MOVC A,@A+DPTR
- MOV P0,A
- LCALL DELAY
- MOV A,MIN
- MOV B,#10
- DIV AB
- CLR P3.0
- SETB P3.3
- MOVC A,@A+DPTR
- MOV P0,A
- LCALL DELAY
- MOV A,B
- CLR P3.3
- SETB P3.2
- MOVC A,@A+DPTR
- MOV P0,A
- LCALL DELAY
- MOV A,HOUR
- MOV B,#10
- DIV AB
- CLR P3.2
- SETB P3.5
- MOVC A,@A+DPTR
- MOV P0,A
- LCALL DELAY
- MOV A,B
- CLR P3.5
- SETB P3.4
- MOVC A,@A+DPTR
- MOV P0,A
- LCALL DELAY
- RET
- DELAY: MOV R6,#10
- K:MOV R7,#200
- DJNZ R7,$
- DJNZ R6,K
- RET
- SETTAB: DB 03H,9FH,25H,0DH,99H,49H,41H,1FH,01H,09H,0FFH
- END
复制代码
|