《数字钟说明书.docx》由会员分享,可在线阅读,更多相关《数字钟说明书.docx(6页珍藏版)》请在优知文库上搜索。
1、20.数字钟()1 .实验任务(1.开机时,显示12:00:00的时间开场计时;(2.PO.0/ADO控制“秒”的调整,每按一次加1秒;(3.POJ/ADl控制“分”的调整,每按一次加1分;(4.P0.2/AD2控制时”的调整,每按一次加1个小时;2 .电路原理图图4.20.13 .系统板上硬件连线(1.把“单片机系统区域中的PI.0-PI.7端口用8芯排线连接到“动态数码显小区域中的A-H端口上;(2.把“单片机系统:区域中的P3.0-P3.7端口用8芯排线连接到“动态数码显示”区域中的Sl-S8端口上;(3.把“单片机系统”区域中的P0.0AD0、P0.1/ADKPO.2/AD2端口分别用
2、导线连接到“独立式键盘区域中的SP3、SP2、SPl端口上;4 .相关基本知识(1.动态数码显示的方法(2.独立式按键识别过程(3.“时,分,“秒数据送出显示处理方法5 .程序框图开始1计.单元清零TH0,TL0装入初值r壬断;台,-TOL理上二哀梏键想即成IJl最二二SECOND1J111-EeGND-OI、口显示教幅处理介.键.即涉工力否二MINITEll111MINITE=60MI-)-、显示热桐处理HWlhVIJiHOURJl111HQUR=24H。R0/,xTO中断入口通过查表方式显示数据位选数值=8吗秒计数加1秒计数=0SECgjD=O,并MltjWE加-MINnT:=60谕)MI
3、NITE=O.HOUR加HCUR=24CHQlJR=O显示数据处理中断返回SECONDEQU30HMINITEEQU3IHHOUREQU32HHOURKBITP0.0MINITEKBITP0.1SECONDKBITP0.2DISPBUFEQU40HDISPBITEQU48HT2SCNTAEQU49HT2SCNTBEQU4AHTEMPEQU4BHORGOOHljmpstartORGOBIILJMPINT-TOSTART:MOVSECOND,#00HMOVMINrrE制X)HMOVHOUR,#12MOVDISPBIT.#OOHMOVT2SCNTA,MX)HMOVT2SCNTB.#00HMOVTEM
4、P,#OFEHLCALLDISPMoVTMoD.#01HMOVTH0,#(65536-2000)/256MOVTLO.#(65536-2000)MOD256SETBTROSETBETOSETBEAWT:JBSECONDK,NKl1.CALLDELY10MSJBSECONDK,NK1INCSECONDMOVA.SECONDCJNEA,#60,NS60MOVSECOND,#(X)HNS60:LCALLDISPJNBSECONDK5NKI:JBMINITEK,NK21.calldelyiomsJBMIN1TEK,NK2INCMINITEMOVA,MINITECJNEA,#60,NM60MOVMlNr
5、rE阴X)HNM60:LCALLDISPJNBMINITEK,$NK2:JBHOURK,NK31.calldelyiomsJBHOURK.NK3INCHOURMOVA.HOURCJNEA,#24,NH24MOVHOUR,MX)HNH24:LCALLDISPJNBHoURK.$NK3:UMPWTDELY10MS:MOVR6,#10Dl:MOVR7,#248DJNZR7,SDJNZR6,D1RETDISP:MOVA,#DISPBUFADDA,#8DECAMOVRl,AMOVA,HOURMOVB.#10DIVABMOVR1,ADECRlMOVA,BMOVR1,ADECRlMOVA,#10MOVRI,
6、ADECRlMOVA,MINITEMOVB,#10DIVABMOVR1,ADECRlMOVA,BMOVR1,ADECRlMOVA,#10MOVR1,ADECRlMOVA,SECONDMOVB,#10DIVABMOVR1,ADECRlMOVA.BMOVR1,ADECRlRETINT_T0:MOVTHO,#(65536-2(X)O)/256MOVTLo.#(65536-2000)MOD256MOVA,#DlSPBUFADDA,DISPBITMOVR0,AMOVA,ROMOVDPTR,#TABLEMOVCA,A+DPTRMOVPl,AMOVA.DISPBITMOVDPTR,#TABMOVCA.A+D
7、PTRMOVP3,AINCDISPBITMOVA,DISPBITCJNEA,#08H,KNAMOVDISPBIT,#OOHKNA:INCT2SCNTAMOVA,T2SCNTACJNEA.#100.DONEMOVT2SCNTA,#00HINCT2SCNTBM0VA.T2SCNTBCJNEA.#05H.DONEMOVT2SCNTB.三)HINCSECONDMOVA,SECONDCJNEA,#60,NEXTMOVSECOND.#OOHINCMINlTEMOVA,MINITECJNEA,#60,NEXTMOVMlNrrE,维X)HINCHOURMOVA,HOURCJNEA,#24,NEXTMOVHOU
8、R,#OOHNEXT:LCALLDISPDONE:RETITABLE:DB3FH.06H,5BH,4FH.66H,6DH,7DH,07H,7FH,6FH.40HTAB:DB0FEH.0FDH.0FBH.0F7H,0EFH.0DFH.0BFH.07FHEND7.C语言源程序includeunsignedcharcodedispcode=0x3f,0x06,0x5b,0x4f.0x66,0x6d,0x7d,0x07,Ox7f,Ox6f,Ox77,Ox7c,0x39,0x5e,0x79.0x71,0x00;unsignedchardispbitcode=0xfe,0xfd,0xfb,0xf7,0xe
9、f,0xdf,0xbf,0x7f);unsignedchardispbuf8=0,0,16,0.0,16,0,0;unsignedchardispbitcnt;unsignedcharsecond;unsignedcharminite;unsignedcharhour;unsignedinttent;unsignedcharms(cnt;unsignedchari,j;voidmain(void)(TMOD=0x02;TH0=0x06;TL0=0x06;TRO=1;ETO=1;EA=I;while(l)(if(PO_O=O)(for(i=5;i0;i)for(j=248;jX);j-);if(
10、PO_O=O)second+;if(second=60)(second=0;dispbufIO)=second%10;dispbuf1=second/10;while(P0_0=0);)if(PO_l=O)(for(i=5;i0;i-)for(j=248y0y-);if(PO_l=O)(minite+;if(minite=60)(minite=0;dispbu113=minite%1();dispbuf4=minitelO;while(PO=O);Iif(P0.2=0)(for(i=5;i0;i-)for(j=248X)y-);if(P0_2=0)(hour+;if(hour=24)hour=
11、0;dispbuf6=hour%10;dispbuf7=hour10;WhiIe(P0_2=0);)voidtO(void)interrupt1using0(mscnt+;if(mstcnt=8)(mstcnt=0:P1=dispcodedispbufdispbitcnt;P3=dispbitcodedispbitcntJ;dispbitcnt+;if(dispbitcnt=8)(dispbitcnt=O;tent+;if(tcnt=4000)(tcnt=O;second+;if(second=60)(second=0;minite+;if(minite=60)minite=0;hour+;if(hour=24)hour=0;)dispbuf0=second%10;dispbufl=secondI0:dispbuf3=minite%10;dispbuf4=minite/10;dispbufl6=hour%10:dispbuf7=hour10;)I