用8031單片機(jī)控制的數(shù)字鐘
MOV A,30H
MOVX @R1,A
MOV R0,31H
MOV A,@R0
MOV DPTR,#SC
MOVC A,@A+DPTR
MOV R1,#22H
MOVX @R1,A
LCALL D1
MOV A,30H
RR A
MOV 30H,A
DEC 31H
DJNZ R7,SS1
DJNZ R6,SS2
RET
SC: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H,0FFH
KEY: MOV 42H,#00H
A0: MOV P1,#0FFH
MOV A,P1
ANL A,#38H
MOV R3,A
LCALL DELAY
MOV P1,#0FFH
MOV A,P1
ANL A,#38H
CLR C
SUBB A,R3
JNZ A0
MOV A,R3
CJNE A,#38H,A00
SJMP A0
A00: CJNE A,#30H,TOK2
INC 41H
MOV R2,41H
CJNE R2,#3CH,A1
MOV 41H,#00H
A1: MOV P1,#0FFH
MOV A,P1
ANL A,#08H
JNZ A0
LCALL DELAY
SJMP A1
TOK2: CJNE A,#28H,TOK3
DEC 41H
MOV R2,41H
CJNE R2,#0FFH,A2
MOV 41H,#3BH
A2: MOV P1,#0FFH
MOV A,P1
ANL A,#10H
JNZ A0
LCALL DELAY
SJMP A2
TOK3: CJNE A,#18H,A0
AA: MOV P1,#0FFH
MOV A,P1
ANL A,#20H
JNZ A3
LCALL DELAY
SJMP AA
A3: MOV P1,#0FFH
MOV A,P1
ANL A,#38H
MOV R3,A
LCALL DELAY
MOV P1,#0FFH
MOV A,P1
ANL A,#38H
CLR C
SUBB A,R3
JNZ A3
MOV A,R3
CJNE A,#38H,A33
SJMP A3
A33: CJNE A,#30H,TO2
INC 40H
MOV R2,40H
CJNE R2,#18H,A4
MOV 40H,#00H
A4: MOV P1,#0FFH
MOV A,P1
ANL A,#08H
JNZ A3
LCALL DELAY
SJMP A4
TO2: CJNE A,#28H,TO3
DEC 40H
MOV R2,40H
CJNE R2,#0FFH,A5
MOV 40H,#17H
A5: MOV P1,#0FFH
MOV A,P1
ANL A,#10H
JNZ A3
LCALL DELAY
SJMP A5
TO3: CJNE A,#18H,A3
RET
KEY0: MOV 41H,21H
MOV 40H,20H
CLR TR0
ACALL KEY
CLR PSW.5
MOV 22H,42H
MOV 21H,41H
MOV 20H,40H
MOV TL0,#0B7H
MOV TH0,#3CH
SETB TR0
RET
KEY1: MOV 41H,51H
MOV 40H,50H
LCALL KEY
CLR 7FH
MOV 51H,41H
MOV 50H,40H
RET
D1: MOV R4,#02H
D11: MOV R5,#0FFH
DJNZ R5,$
DJNZ R4,D11
RET
DELAY: PUSH ACC
LCALL CUTIN1
LCALL SSCAN
POP ACC
RET本文引用地址:http://butianyuan.cn/article/172074.htm
評(píng)論