这是单片机时钟程序
附件包括源程序,不包含proteus仿真
源码下载:
新建 Microsoft Word 文档.docx
(13.83 KB, 下载次数: 7)
- LEDBUF EQU 60H
- HOUR EQU 40H
- MINTUE EQU 41H
- SECOND EQU 42H
- ORG 0000H
- LJMP MAIN
- ORG 000BH
- LJMP T0P
- LEDMAP:DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
- ORG 1000H
- MAIN:MOV TMOD,#01H
- MOV R5,#10
- MOV HOUR,#23
- MOV MINTUE,#59
- MOV SECOND,#55
- SETB ET0
- SETB EA
- SETB TR0
- LOOP:MOV A,HOUR
- MOV B,#10
- DIV AB
- CALL ZH
- MOV LEDBUF,A
- MOV A,B
- CALL ZH
- ORL A,#80H
- MOV LEDBUF+1,A
- MOV A,MINTUE
- MOV B,#10
- DIV AB
- CALL ZH
- MOV LEDBUF+2,A
- MOV A,B
- CALL ZH
- ORL A,#80H
- MOV LEDBUF+3,A
- MOV A,MINTUE
- MOV B,#10
- DIV AB
- CALL ZH
- MOV LEDBUF+4,A
- MOV A,B
- CALL ZH
- ORL A,#80H
- MOV LEDBUF+5,A
- CALL DISPLAY
- LJMP LOOP
-
- ZH:MOV DPTR,#LEDMAP
- MOVC A,@A+DPTR
- RET
- DISPLAY:MOV R1,#6
- MOV R0,#LEDBUF
- MOV R2,#20H
- LOOP1:MOV DPTR,#8002H
- MOV A,#00H
- MOVX @DPTR,A
- MOV DPTR,#8004H
- MOV A,@R0
- MOVX @DPTR,A
- MOV DPTR.#8002H
- MOVX A,R2
- MOVX @DPTR,A
- CALL DELAY
- INC R0
- MOV A,R2
- RRA
- MOV R2,A
- DJNZ R1,LOOP
- MOV DPTR,#8002H
- MOV A,#00H
- MOVX @DPTR,A
- RET
-
- T0P:push PSW
- push Acc
- mov TL0,#0B0H
- mov TH0,#3CH
- DJNZ R5,EXIT
- mov R5,#10
- mov A,#01H
- ADD A,SECOND
- mov SECOND,A
- CJNE A,#60,EXIT
- mov SECOND,#00H
- mov A,#01H
- ADD A,MINUTE
- mov MINUTE,A
- CJNE A,#60,EXIT
- mov MINUTE,#00H
- mov A,#01H
- ADD A,HOUR
- mov HOUR,A
- CJNE A,#24,EXIT
- mov HOUR,#00H
- EXIT:POP PSW
- POP ACC
- RETI
- DELAY:MOV R6,#20
- DEL1:MOV R7,#12
- DEL2:DJNZ R7,DEL2
- DJNZ R6,DEL1
- RET
- END
复制代码
|