电子钟流程图+原理图+源代码 第3页
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: MOV @R1,A
POP PSW
POP ACC
RETI
KEY1: CLR ET1 ;外部中断一中断程序,完成状态的调整
PUSH ACC
PUSH PSW
SETB www.751com.cn
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
结 束 语
在经过了三,四个月紧张的毕业设计后,感觉自己无论是对单片机编程方面的认识,还是上机调试制图方面的能力都进了一大步,受益不少。由于本人水平有限,经验不足及阅历尚浅,程序和论文中难免有许多不足之处,还望老师多多指出和纠正。