哪位有基于单片机的多功能数字电子钟的开题报告

2024-12-26 16:20:22
推荐回答(1个)
回答1:

源程序如下:ORG0000H;程序开始入口LJMPSTARTORG0003H;外中断0中断程序入口RETIORG000BH;定时器T0中断程序入口LJMPINTT0;跳至INTTO执行ORG0013H;外中断1中断程序入口RETIORG001BH;定时器T1中断程序入口LJMPINTT1ORG0023H;串行中断程序入口地址RETI;---------------主程序----------------------;START:MOVR0,#70H;70给R0,清70-7FH显示内存MOVR7,#0FHCLEARDISP:MOV@R0,#00H;0给R0中的数为地址的内存中存放(70H)INCR0DJNZR7,CLEARDISPMOV78H,#2;默认时间为12:00,闹钟5:00MOV79H,#1MOV74H,#2;防止上电时数码管显示00小时MOV75H,#1MOV66H,#1;中断退出时66H为1时,分、时计时单元数据移入显存标志MOV68H,#1;上电默认闹钟开状态MOV7DH,#6;闹钟时十位MOV7CH,#3MOV69H,#0MOV7AH,#0AH;放入"熄灭符"数据MOVTMOD,#11H;设T0、T1为16位定时器MOVTL0,#0B0H;50MS定时初值(T0计时用)MOVTH0,#3CHSETBEA;总中断开放SETBET0;允许T0中断SETBTR0;T0定时器开始计时MOVR4,#14H;1秒定时用初值(50MS×20)START1:LCALLDISPLAY;显示子程序LCALLBEEP;闹钟查询JNBP1.7,SETTIME;P1.7口为0时转时间调整程序JMPSTART1;P1.7口为1时跳回START1;-----------------------时间闹钟调整系统--------------------------;NFLAG:MOVA,68H;设置闹钟开关状态CJNEA,#1,BEE68MOV68H,#0JMPE6BEE68:MOV68H,#1E6:MOV66H,#8;中断退出66H不为1时分、时计时单元数据移入显存标志MOV72H,7BHMOV73H,7CHMOV74H,7DHMOV75H,7EHLCALLDDLLCALLDDLMOV72H,68HMOV73H,69HMOV74H,7AHMOV75H,7AHLCALLDDLLCALLDDLMOV66H,#1LJMPSTART1SETTIME:LCALLDDLJBP1.7,NFLAG;键按下时间小于1秒,设置闹钟开关状态并查看闹钟时间,不关走时,确保准确,大于1秒调时MOVTL1,#0B0H;T1闪烁定时初值MOVTH1,#3CHMOVR2,#06H;进入调时状态,赋闪烁定时初值MOV66H,#8;调闹钟时保持走时,关闭时钟显示数据SETBET1;允许T1中断SETBTR1;开启定时器T1SET1:LCALLDISPLAY;调用显示,防止键按下无显示JNBP1.7,SET1;P1.7口为0等待键释放MOVR5,#00H;清设置类型闪烁标志SETN1:INCR5;闹钟分调整SET5:LCALLDISPLAYJBP1.7,SET5SEETN1:LCALLDDL;有键按下大于1秒分时间连续加(0.5秒加1),小于1秒转调时状态JBP1.7,SET6;键释放查询,键释放自动转调时MOVR0,#7CHLCALLADD1MOVA,R3CLRCCJNEA,#60H,HHN1HHN1:JCSEETN1LCALLCLR0JMPSEETN1SET6:INCR5;闹钟时调整SEET6:LCALLDISPLAYJBP1.7,SEET6SEETNH1:LCALLDDLJBP1.7,SETFMOVR0,#7EHLCALLADD1MOVA,R3CLRCCJNEA,#24H,HOUU1HOUU1:JCSEETNH1LCALLCLR0JMPSEETNH1SETF:LCALLDISPLAYJBP1.7,SETFLCALLDDLJNBP1.7,SETOUT;短按调时,长按退出CLRET0CLRTR0MOV70H,#00H;设定后的时间从00秒开始走时MOV71H,#00HINCR5SET3:LCALLDISPLAYJBP1.7,SET3SETMM:LCALLDDLJBP1.7,SET4MOVR0,#77HLCALLADD1MOVA,R3CLRCCJNEA,#60H,MMHMMH:JCSETMMLCALLCLR0AJMPSETMMSET4:INCR5SEET4:LCALLDISPLAYJBP1.7,SEET4SETHH:LCALLDDLJBP1.7,SETOUT1MOVR0,#79HLCALLADD1MOVA,R3CLRCCJNEA,#24H,HOUUHOUU:JCSETHHLCALLCLR0AJMPSETHHSETOUT1:SETBET0SETBTR0;计时开始SETOUT:MOVR5,#00H;清设置类型闪烁标志CLRTR1;关闭T1CLRET1;关T1中断MOV66H,#1SETOUT2:LCALLDISPLAYJNBP1.7,SETOUT2LJMPSTART1;--------------------------延时1秒钟-----------------------;DDL:MOV18H,#36DDL0:MOV17H,#239DDL1:LCALLDISPLAYDJNZ17H,DDL1DJNZ18H,DDL0RET;----------------------------T0中断程序------------------------;INTT0:PUSHACC;打包PUSHPSWCLRET0CLRTR0MOVA,#0B7HADDA,TL0MOVTL0,AMOVA,#3CHADDCA,TH0MOVTH0,ASETBTR0DJNZR4,OUTT0;20次中断未到中断退出ADDSS:MOVR4,#14H;20次中断到(1秒)重赋初值MOVR0,#71H;指向秒计时单元(70-71H)ACALLADD1;调用加1程序(加1秒操作)MOVA,R3;秒数据放入A(R3为2位十进制数组合)CLRC;清进位标志CJNEA,#60H,ADDMMADDMM:JCOUTT01;小于60秒退出ACALLCLR0;等于或大于60秒清0MOVR0,#77H;指向分计时单元(76H-77H)ACALLADD1MOVA,R3CLRCCJNEA,#60H,ADDHHADDHH:JCOUTT0ACALLCLR0MOVR0,#79H;指向小时计时单元(78H-79H)ACALLADD1MOVA,R3CLRCCJNEA,#24H,HOURHOUR:JCOUTT0ACALLCLR0OUTT0:MOVA,66H;查询标志CJNEA,#1,OUTT01MOV72H,76H;中断退出时将分、时计时单元数据移入对应显示单元MOV73H,77HMOV74H,78HMOV75H,79HOUTT01:POPPSW;出栈POPACCSETBET0;开放T0RETI;中断返回;---------------------------加1程序--------------------------;ADD1:MOVA,@R0;取当前计时单元数据到ADECR0;指向前一地址SWAPA;A中数据高四位与低四位交换ORLA,@R0;前一地址中数据放入A中低四位ADDA,#01H;A加1操作DAA;十进制调整MOVR3,A;移入R3寄存器ANLA,#0FH;高四位变0MOV@R0,A;放回前一地址单元MOVA,R3;取回R3中暂存数据INCR0;指向当前地址单元SWAPA;A中数据高四位与低四位交换ANLA,#0FH;高四位变0MOV@R0,A;数据放入当削地址单元中RETCLR0:CLRCCLRA;清累加器MOV@R0,A;清当前地址单元DECR0;指向前一地址MOV@R0,A;前一地址单元清0RET;子程序返回;-------------------------调时闪烁程序----------------------;INTT1:PUSHACCPUSHPSWMOVTL1,#0B0HMOVTH1,#3CHDJNZR2,INTT1OUT;0.3秒未到退出中断(50MS中断6次)MOVR2,#06H;重装0.3秒定时用初值CPL02H;0.3秒定时到对闪烁标志取反JB02H,FLASH1;02H位为1时显示单元"熄灭"MOVA,R5CJNEA,#01H,NLJMPNNN1NL:CJNEA,#02H,NL1LJMPNNN1NL1:CJNEA,#03H,NL2LJMPNLLNL2:CJNEA,#04H,INTT1OUTLJMPNLLNLL:MOV72H,76HMOV73H,77HMOV74H,78HMOV75H,79HAJMPINTT1OUTNNN1:MOV72H,7BHMOV73H,7CHMOV74H,7DHMOV75H,7EHINTT1OUT:POPPSW;恢复现场POPACCRETI;中断退出FLASH1:MOVA,R5CJNEA,#01H,MLLJMPMNN1ML:CJNEA,#02H,ML1LJMPMNN2ML1:CJNEA,#03H,MNLJMPMLLMN:CJNEA,#04H,INTT1OUTLJMPMHLMLL:MOV72H,7AHMOV73H,7AH;显示单元(72-73H),将不显示分数据MOV74H,78HMOV75H,79HAJMPINTT1OUTMHL:MOV72H,76HMOV73H,77HMOV74H,7AH;显示单元(74-75H),小时数据将不显示MOV75H,7AHAJMPINTT1OUTMNN1:MOV72H,7AHMOV73H,7AH;显示单元(72-73H),将不显示闹钟分数据MOV74H,7DHMOV75H,7EHAJMPINTT1OUTMNN2:MOV72H,7BHMOV73H,7CHMOV74H,7AHMOV75H,7AH;显示单元(74-75H),闹钟小时数据将不显示AJMPINTT1OUT;-------------------------显示-------------------------------;DISPLAY:MOVDPTR,#DISDATAMOVA,70HMOVCA,@A+DPTRMOVP3,ACLRP1.0NOPNOPNOPSETBP1.0MOVA,71HMOVCA,@A+DPTRMOVP3,ACLRP1.1NOPNOPNOPSETBP1.1MOVA,72HMOVCA,@A+DPTRMOVP3,ACLRP1.2NOPNOPNOPSETBP1.2MOVA,73HMOVCA,@A+DPTRMOVP3,ACLRP1.3NOPNOPNOPSETBP1.3MOVA,74HMOVCA,@A+DPTRMOVP3,ACLRP1.4NOPNOPNOPSETBP1.4MOVA,75HMOVCA,@A+DPTRMOVP3,ACLRP1.5NOPNOPNOPSETBP1.5RETBEEP:MOVA,68H;查询标志CJNEA,#1,BEEREMOVA,78H;查询闹钟时个位CJNEA,7DH,BEEREMOVA,79H;查询闹钟时十位CJNEA,7EH,BEEREMOVA,76H;查询闹钟分个位CJNEA,7BH,BEEREMOVA,77H;查询闹钟分十位CJNEA,7CH,BEEREBB:CLRP1.6LCALLDDLSETBP1.6LCALLDDLJNBP1.7,BEERRBEERE:RETBEERR:SETBP1.6MOV68H,#0LCALLDISPLAYJNBP1.7,BEERRJMPBEEREDISDATA:DB0C0H,0F9H,64H,70H,59H,52H,42H,0F8H,40H,50H,0FFH;0123456789空白END