西南科技大学本科生毕业论文I基于单片机的多功能数字钟的设计摘要:本设计论文介绍了用AT89C2051单片机控制的数字钟的硬件结构与软件设计,给出了汇编语言源程序。此数字钟是一个将“时”、“分”、“秒”显示于人的视觉器官的计时装置。它的计时周期为12小时,显示满刻度为12时59分59秒99毫秒,另外应有校时功能。电路由时钟脉冲发生器、时钟计数器、译码驱动电路和数字显示电路以及时间调整电路组成。用晶体振荡器产生时间标准信号,这里采用石英晶体振荡器。根据60秒为1分、60分为1小时、24小时为1天的计数周期,分别组成两个60进制(秒、分)、一个12进制(时)的计数器。构成秒、分、时的计数,实现计时的功能。显示器件选用LED七段数码管。在译码显示电路输出的驱动下,显示出清晰、直观的数字符号。针对数字钟会产生走时误差的现象,在电路中就设计有有校准时间功能的电路。关键词:单片机;AT89C2051;数字钟;计时西南科技大学本科生毕业论文IIBasedonSCMmulti-purposedigitalclockdesignAbstract:ThepapermainlypresentsthehardwareandsoftwaredesignofthedigitalclockusingAT89C2051.ThesourceprogramusingassembleLanguageisgiven.Thisdigitalclockisatime-device,whichcandisplayhour,minute,second.Itstimeperiodis12hoursandthefullscaleofthedisplayis12hours,59minutes,59secondsand99millisecondsandithasthefunctionoftimeadjustment.Thecircuitconsistsoftheclockpulsegenerator,theclockcounter,decodingdrivecircuit,digitaldisplaycircuitandthetimeadjustmentcircuit.Itgeneratestimestandardsignalusingcrystaloscillator,hereisthequartzcrystaloscillator.Because60secondsis1minute,60minutesis1hourand24hoursis1day,weusestwocountersof60partsandacounterof12partseparatelytoconstitutethecountofpercentageofsecond,second,minute,andhour.Soitcanrealizetimefunction.Displaycomponentselectsseven-segmentnumericaltubeLED.Drivenbydecodingoutputcircuit,itcandisplayshowingclearandintuitivefigures.Duetowalkingerrorofdigitalclock,wedesigntimecalibrationcircuitinthesystem.Keywords:Single-chipmicrocomputer;AT89C2051;Digitalclock;Time西南科技大学本科生毕业论文III目录第1章绪论····························································································11.1前言·······························································································11.2设计的目的及意义·············································································1第2章数字钟的功能实现与设计方案······························································22.1数字钟的功能及设计要求····································································22.2数字钟的实现形式·············································································22.3方案的确定······················································································32.3.1微处理器·················································································32.3.2显示电路·················································································32.3.3按键电路·················································································4第3章数字钟的硬件系统设计·······································································53.1数字时钟的硬件系统框架····································································53.2数字时钟的主机电路设计····································································53.2.1系统控制芯片CPU(AT89C2051)的选择·······································53.2.2系统时钟电路设计····································································103.2.3系统复位电路设计····································································123.2.4按键与按钮电路设计·································································133.2.5闹铃声光指示电路设计······························································133.2.6数字钟的显示电路设计······························································133.3校时电路设计··················································································173.3.1校时原理················································································183.3.2国家授时中心··········································································183.3.3窗口比较器·············································································193.3.4校时电路电路图·······································································203.4电源设计························································································20第4章程序设计························································································244.1主控模块设计··················································································24西南科技大学本科生毕业论文IV4.2基本现实模块设计············································································254.3当前编辑位闪烁功能的实现································································264.4时间设定模块设计············································································264.5脉冲发生器原理与走时处理································································274.6闹铃功能的实现···············································································28第5章系统的调试及结果············································································305.1系统调试环境··················································································305.2软件调试························································································305.3硬件调试························································································305.4调试结果························································································30结论··································································································31致谢··································································································32参考文献···················