《基于单片机的数字电子钟设计与制作2pdf.doc》由会员分享,可在线阅读,更多相关《基于单片机的数字电子钟设计与制作2pdf.doc(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、ORG 0AJ MP MAINORG 000BHAJ MP TI METI ME: CLR TR0MOV TH0 , #3CHMOV TL0 , #0B8 HSETB TR0MOV 09H, R0I NC 16HMOV R0 , 16HMOV A, R0CLR CCJNE A, 21H, TMMI NC 16HMOV R0 , 16 HI NC 16HMOV A, R0CLR CCJNE A, 22H, TTMMOV 19H, #45 H ; 19H 作为时间到标志AJ MP TTMTMM: I NC 16HI NC 16HTTM: MOV R0, 09HDJNZ 18H, OUT0MOV 1
2、8 H, #20MOV 16 H, #23HMOV A, R2; 控制闪烁CLR CSUBB A, #5JZ TMMOV A, 1BHCPL AMOV 1BH, AANL A, R4MOV 1AH, ATM: MOV A, 17HCLR CS UBB A, #23HJZ OUT0SEC: I NC 20HMOV A, 20HCLR CCJNE A, #60, OUT0MOV 20H, #0MIN: I NC 21HMOV 19 H, #0; 一分钟到关闹铃CLR P1. 7MOV A, 21 HCLR CCJNE A, # 60 , OUT0MOV 21 H, #0HOUR: I NC 22H
3、MOV A, 22HCLR CCJNE A, #24, OUT0MOV 22H, #0OUT0 : RET IDISP: MOV R0 , #10 H ; 10H 作为显存首址MOV R7 , #7FHMOV R6 , #7TO: MOV A, R0MOVC A, A+ DPTRORL A, #80HPUS H ACCMOV A, R7RL AMOV R7 , AORL A, 1AH ; 1AH 控制闪烁MOV P0 , #0MOV P2 , A; P2为位选POP ACCMOV P0 , A; P0作为段选INC R0DJNZ R6 , TORETCHAI : MOV A, R1MOV B,
4、 #10DI V ABMOV 10H, BMOV 11H, AI NC R1MOV A, R1MOV B, #10DI V ABMOV 12H, BMOV 13H, AI NC R1MOV A, R1MOV B, #10DI V ABMOV 14H, BMOV 15H, ADEC R1DEC R1RETTSH I : MOV A, R2; R2作为调时与定时的标志CLR CS UBB A, #0F0HJZ GO2MOV R2 , #0FHMOV A, R4RR ARR AMOV R4 , ACLR CCJNE A, #00110000B, GOMOV R3 , #22 HGO: CLR CCJ
5、NE A, #00001100B, GO1MOV R3 , #21 HGO1 : CLR CCJNE A, #00000011B, GO3MOV R3 , # 20 HGO3 : CLR CCJNE A, #11000000B, GO2MOV A, 17HCLR CCJNE A, #23H, GO4CLR TR0MOV TH0 , #3CHMOV TL0, #0B8 HSETB TR0MOV 17H, #0GO4 : MOV R2 , #0GO2 : RETDSH I : MOV A, R2; R2作为调时与定时的标志CLR CS UBB A, #0FHJZ DSOUT1MOV R2 , #
6、0F0 HMOV A, R4RL ARL AMOV R4 , ACLR CCJNE A, #00001100B, DSOUT2I NC R1MOV A, R1MOV R3 , ADEC R1DSOUT2 : MOV A, R4CLR CCJNE A, #00110000B, DSOUT3I NC R1I NC R1MOV A, R1MOV R3 , ADEC R1DEC R1DSOUT3 : MOV A, R4CLR CCJNE A, #00000011B, DSOUT4INC R1INC R1INC R1DSOUT4 : MOV A, R4CLR CCJNE A, #11000000B, D
7、SOUT1MOV R4 , # 00000011BMOV R3 , # 0FHI NC R1I NC R1I NC R1DSOUT1 : RETXSH I : MOV A, R2CLR CS UBB A, # 5JZ XSOUT3MOV A, R3MOV R0 , AI NC R0MOV A, R4CLR CCJNE A, #00000011B, XSOUTMOV A, R2; R2作为调时与定时的标志CLR CCJNE A, #0FH, XSOUT4MOV R0, #0MOV 17H, #23HXSOUT4 : MOV A, R2; R2作为调时与定时的标志CLR CCJNE A, #0F0
8、 H, XSOUTMOV 17 H, #0MOV R4 , #11000000BMOV R1 , #20HMOV R2 , #5XSOUT: MOV A, R4CLR CCJNE A, # 00110000B , XSOUT2MOV A, R0CLR CSUBB A, #24JC XSOUT1MOV R0 , # 0XSOUT2 : MOV A, R4CLR CCJNE A, #00001100B, XSOUT1MOV A, R0CLR CSUBB A, #60JC XSOUT1MOV R0 , # 0AJ MP XSOUT1XSOUT3 : MOV A, R5CPL AMOV R5 , AC
9、PL P1. 0; P1 . 0闹铃开关指示灯XSOUT1 : RETMAI N:MOV 10H, # 0MOV 11H, # 0MOV 12H, # 0MOV 13H, # 0MOV 14H, # 0MOV 15H, # 0MOV 20H, # 0MOV 21H, # 0MOV 22H, # 0MOV 23H, # 1MOV 26H, # 2MOV 29H, # 3MOV 2CH, # 4MOV 2FH, #5MOV 32H, # 6MOV 35H, # 7MOV 38H, # 8MOV 3BH, # 9MOV 3EH, # 10MOV 41H, # 11MOV 44H, # 12MOV 4
10、7H, # 13MOV 4AH, #14MOV 4DH, #15MOV 50H, # 16MOV 53H, # 17MOV 56H, # 18MOV 59H, # 19MOV 5CH, # 20MOV 16H, # 23CLR P1 . 2CLR P1 . 4CLR P1 . 6CLR P1 . 7MOV SP, # 60 HMOV DPTR, #TABMOV R1 , #20H ; R1作为拆分地址首MOV R4 , #11000000BMOV R2 , #5; R2作为定时, 调时选择MOV R5 , #00111100B; R5作为闹铃开关MOV 1BH, # 0MOV 18H, # 2
11、0MOV P0 , # 0MOV P2 , # 0MOV IE, # 87 HSETB IT0SETB IT1MOV IP, #2; 设 T0优先级最高MOV TMOD, #1; 定时器模式 1MOV TH0, #3CHMOV TL0 , #0B8HSETB TR0CLR EX0CLR EX1START: ACALL CHAIACALL DISPRI NG: MOV A, R5CLR CCJNE A, #00111100B, SS0MOV A, 19HCLR CCJNE A, #45H, SS0CPL P1 . 7SS0 : JNB P1 . 6 , SS1ACALL DELJNB P1 . 6 , SS1ACALL TS H ICLR P1 . 6SS1 : JNB P1 . 4 , SS2ACALL DELJNB P1 . 4, SS2ACALL XSH ICLR P1 . 4SS2 : JNB P1 . 2, SS3ACALL DELJNB P1 . 2, SS3ACALL DSH ICLR P1 . 2SS3 : AJMP STARTDEL: DJNZ 1DH, $DJNZ 1CH, DELRETTAB : DB 3FH, 6H, 5BH, 4FH, 66H, 6DH, 7DH,7 H, 7FH, 6FHEND学习文档 仅供参考