基于单片机的数字电子钟设计与制作2pdf.docx
《基于单片机的数字电子钟设计与制作2pdf.docx》由会员分享,可在线阅读,更多相关《基于单片机的数字电子钟设计与制作2pdf.docx(10页珍藏版)》请在冰豆网上搜索。
基于单片机的数字电子钟设计与制作2pdf
基于单片机的数字电子钟设计与制作2pdf
ORG0
AJMPMAIN
ORG000BH
AJMPTIME
TIME:
CLRTR0
MOVTH0,#3CH
MOVTL0,#0B8H
SETBTR0
MOV09H,R0
INC16H
MOVR0,16H
MOVA,@R0
CLRC
CJNEA,21H,TMM
INC16H
MOVR0,16H
INC16H
MOVA,@R0
CLRC
CJNEA,22H,TTM
MOV19H,#45H;19H作为时间到标志
AJMPTTM
TMM:
INC16H
INC16H
TTM:
MOVR0,09H
DJNZ18H,OUT0
MOV18H,#20
MOV16H,#23H
MOVA,R2;控制闪烁
CLRC
SUBBA,#5
JZTM
MOVA,1BH
CPLA
MOV1BH,A
ANLA,R4
MOV1AH,A
TM:
MOVA,17H
CLRC
SUBBA,#23H
JZOUT0
SEC:
INC20H
MOVA,20H
CLRC
CJNEA,#60,OUT0
MOV20H,#0
MIN:
INC21H
MOV19H,#0;一分钟到关闹铃
CLRP1.7
MOVA,21H
CLRC
CJNEA,#60,OUT0
MOV21H,#0
HOUR:
INC22H
MOVA,22H
CLRC
CJNEA,#24,OUT0
MOV22H,#0
OUT0:
RETI
DISP:
MOVR0,#10H;10H作为显存首址
MOVR7,#7FH
MOVR6,#7
TO:
MOVA,@R0
MOVCA,@A+DPTR
ORLA,#80H
PUSHACC
MOVA,R7
RLA
MOVR7,A
ORLA,1AH;1AH控制闪烁
MOVP0,#0
MOVP2,A;P2为位选
POPACC
MOVP0,A;P0作为段选
INCR0
DJNZR6,TO
RET
CHAI:
MOVA,@R1
MOVB,#10
DIVAB
MOV10H,B
MOV11H,A
INCR1
MOVA,@R1
MOVB,#10
DIVAB
MOV12H,B
MOV13H,A
INCR1
MOVA,@R1
MOVB,#10
DIVAB
MOV14H,B
MOV15H,A
DECR1
DECR1
RET
TSHI:
MOVA,R2;R2作为调时与定时的标志
CLRC
SUBBA,#0F0H
JZGO2
MOVR2,#0FH
MOVA,R4
RRA
RRA
MOVR4,A
CLRC
CJNEA,#00110000B,GO
MOVR3,#22H
GO:
CLRC
CJNEA,#00001100B,GO1
MOVR3,#21H
GO1:
CLRC
CJNEA,#00000011B,GO3
MOVR3,#20H
GO3:
CLRC
CJNEA,#11000000B,GO2
MOVA,17H
CLRC
CJNEA,#23H,GO4
CLRTR0
MOVTH0,#3CH
MOVTL0,#0B8H
SETBTR0
MOV17H,#0
GO4:
MOVR2,#0
GO2:
RET
DSHI:
MOVA,R2;R2作为调时与定时的标志
CLRC
SUBBA,#0FH
JZDSOUT1
MOVR2,#0F0H
MOVA,R4
RLA
RLA
MOVR4,A
CLRC
CJNEA,#00001100B,DSOUT2
INCR1
MOVA,R1
MOVR3,A
DECR1
DSOUT2:
MOVA,R4
CLRC
CJNEA,#00110000B,DSOUT3
INCR1
INCR1
MOVA,R1
MOVR3,A
DECR1
DECR1
DSOUT3:
MOVA,R4
CLRC
CJNEA,#00000011B,DSOUT4
INCR1
INCR1
INCR1
DSOUT4:
MOVA,R4
CLRC
CJNEA,#11000000B,DSOUT1
MOVR4,#00000011B
MOVR3,#0FH
INCR1
INCR1
INCR1
DSOUT1:
RET
XSHI:
MOVA,R2
CLRC
SUBBA,#5
JZXSOUT3
MOVA,R3
MOVR0,A
INC@R0
MOVA,R4
CLRC
CJNEA,#00000011B,XSOUT
MOVA,R2;R2作为调时与定时的标志
CLRC
CJNEA,#0FH,XSOUT4
MOV@R0,#0
MOV17H,#23H
XSOUT4:
MOVA,R2;R2作为调时与定时的标志
CLRC
CJNEA,#0F0H,XSOUT
MOV17H,#0
MOVR4,#11000000B
MOVR1,#20H
MOVR2,#5
XSOUT:
MOVA,R4
CLRC
CJNEA,#00110000B,XSOUT2
MOVA,@R0
CLRC
SUBBA,#24
JCXSOUT1
MOV@R0,#0
XSOUT2:
MOVA,R4
CLRC
CJNEA,#00001100B,XSOUT1
MOVA,@R0
CLRC
SUBBA,#60
JCXSOUT1
MOV@R0,#0
AJMPXSOUT1
XSOUT3:
MOVA,R5
CPLA
MOVR5,A
CPLP1.0;P1.0闹铃开关指示灯
XSOUT1:
RET
MAIN:
MOV10H,#0
MOV11H,#0
MOV12H,#0
MOV13H,#0
MOV14H,#0
MOV15H,#0
MOV20H,#0
MOV21H,#0
MOV22H,#0
MOV23H,#1
MOV26H,#2
MOV29H,#3
MOV2CH,#4
MOV2FH,#5
MOV32H,#6
MOV35H,#7
MOV38H,#8
MOV3BH,#9
MOV3EH,#10
MOV41H,#11
MOV44H,#12
MOV47H,#13
MOV4AH,#14
MOV4DH,#15
MOV50H,#16
MOV53H,#17
MOV56H,#18
MOV59H,#19
MOV5CH,#20
MOV16H,#23
CLRP1.2
CLRP1.4
CLRP1.6
CLRP1.7
MOVSP,#60H
MOVDPTR,#TAB
MOVR1,#20H;R1作为拆分地址首
MOVR4,#11000000B
MOVR2,#5;R2作为定时,调时选择
MOVR5,#00111100B;R5作为闹铃开关
MOV1BH,#0
MOV18H,#20
MOVP0,#0
MOVP2,#0
MOVIE,#87H
SETBIT0
SETBIT1
MOVIP,#2;设T0优先级最高
MOVTMOD,#1;定时器模式1
MOVTH0,#3CH
MOVTL0,#0B8H
SETBTR0
CLREX0
CLREX1
START:
ACALLCHAI
ACALLDISP
RING:
MOVA,R5
CLRC
CJNEA,#00111100B,SS0
MOVA,19H
CLRC
CJNEA,#45H,SS0
CPLP1.7
SS0:
JNBP1.6,SS1
ACALLDEL
JNBP1.6,SS1
ACALLTSHI
CLRP1.6
SS1:
JNBP1.4,SS2
ACALLDEL
JNBP1.4,SS2
ACALLXSHI
CLRP1.4
SS2:
JNBP1.2,SS3
ACALLDEL
JNBP1.2,SS3
ACALLDSHI
CLRP1.2
SS3:
AJMPSTART
DEL:
DJNZ1DH,$
DJNZ1CH,DEL
RET
TAB:
DB3FH,6H,5BH,4FH,66H,6DH,7DH,
7H,7FH,6FH
END