单片机数字时钟设计 第5页
INC R0
RET
CLOCK: ;定时器中断服务程序
JNB P3.0,D4 ;产生定时输出脉冲
CPL P3.4
D4: MOV TL1, #0AFH
MOV TH1, #3CH
PUSH PSW
PUSH ACC
JNB P3.5,C0 ;秒表计数模块
INC MB0
MOV A, MB0
CJNE A, #0AH,C0
MOV MB0, #00H
MOV A, MB1
INC A
DA A
MOV MB1, A
CJNE A, #60H, C0
MOV MB1, #00H
MOV A, MB2
INC A
DA A
MOV MB2, A
CJNE A, #60H, C0
MOV MB2, #00H
C0: JNB 78H, Z1 ;时钟计数程序
INC R6
CJNE R6,#05H,Z1
MOV R6,#00H
CLR 78H
SETB EX0
Z1: JNB 79H, Z2 ;去抖延时程序
INC R6
CJNE R6,#0FH,Z2
MOV R6,#00H
CLR 79H
SETB EX1
Z2: INC BUF
MOV A, BUF
CJNE A, #0AH,QUIT
MOV BUF, #00H
MOV A, SBF
INC A
DA A
MOV SBF, A
CJNE A, #60H, QUIT
MOV SBF, #00H
MOV A, MBF
CLR P3.0 ;定时脉冲输出
一分钟
D2: INC A
DA A
MOV MBF, A
MOV A, FA ;定时比较分值
CJNE A, MBF,D0
SJMP D1
D0: MOV A, MBF
CJNE A, #60H, QUIT
MOV MBF, #00H
MOV A, HOUR
INC A
DA A
MOV HOUR ,A
D1: MOV A,SA ;定时比较时值
CJNE A, HOUR,D3
SETB P3.0
D3: MOV A, HOUR
CJNE A,#18H,QUIT
MOV HOUR,#00H
QUIT: POP ACC
POP PSW
RETI
KEY0: CLR ET1 ;外部中断零服务程序
PUSH ACC
PUSH PSW
SETB ET1
CLR EX0
CLR CY ;清与十进制调整有关的状态位
CLR AC
SETB 78H
JB P3.5,K0
MOV MB0, #00H ; 秒表数据清零
MOV MB1, #00H
MOV MB2, #00H
K0: MOV A,@R1 ;完成加一操作
INC A
DA A
CJNE R1, #26H,K2 ;调整数据的限制
SJMP K3
K2: CJNE R1, #27H,K4
SJMP K3
K4: CJNE A #60H,K1
MOV A,#00H
K3: CJNE A #24H,K1
MOV A,#00H
K1:
www.751com.cn POP ACC
RETI
KEY1: CLR ET1 ;外部中断一中断程序,完成状态的调整
PUSH ACC
PUSH PSW
SETB ET1
CLR EX1
SETB 79H
CJNE R5,#01H,M0
MOV R1,#21H
INC R5
SETB EX0
SJMP EXIT
M0: CJNE R5,#02H,M1
MOV R1,#26H
INC R5
SETB EX0
SJMP EXIT
M1: CJNE R5,#03H,M2
MOV R1,#28H
INC R5
SETB EX0
SJMP EXIT
M2: CJNE R5,#04H,M3
MOV R1,#27H
INC R5
SETB EX0
SJMP EXIT
M3: CJNE R5,#05H,M4
INC R5
MOV R1,#00H
SETB EX0
SJMP EXIT
M4: CJNE R5,#06H,EXIT
MOV R1,#00H
MOV R5,#01H
CLR EX0
EXIT: SETB EX1
POP PSW
POP ACC
RETI
END
上一页 [1] [2] [3] [4] [5]
单片机数字时钟设计 第5页下载如图片无法显示或论文不完整,请联系qq752018766