基于单片机电子钟的设计与实现

华东交通大学毕业设计

电子钟的设计与实现—硬件部分

摘 要

单片计算机即单片微型计算机,是一种集成的电路芯片,是采用超大规模集成电路技术把具有数据处理能力的中央处理器CPU、随机存储器RAM、只读存储器ROM、多种I/O口和中断系统、定时器/计时器等功能(可能还包括显示驱动电路、脉宽调制电路、模拟多路转换器、A/D转换器等电路)集成到一块硅片上构成的一个小而完善的计算机系统。它体积小,成本低,功能强,广泛应用于智能产品和工业自动化上。而51单片机是各单片机中最为典型和最有代表性的一种。本次设计主要为实现一款可正常显示时钟/日历、带有定时闹铃的电子钟。

电子钟主要是利用电子技术将时钟电子化、数字化,拥有时钟精确、体积小、界面友好、可扩展性能强等特点,被广泛应用于生活和工作当中。另外,在生活和工农业生产中,也常常需要电子时钟具有多功能性。

本设计应用AT89S52芯片作为核心,LCD液晶显示,使用DS1302实时时钟日历芯片完成时钟/日历的基本功能。这种实现方法的优点是电路简单,性能可靠,实时性好,时间精度高,操作简单,编程容易。

该电子钟可以应用于一般的生活和工作中,也可通过改装,提高性能,增加新功能,从而给人们的生活和工作带来更多的方便。

关键词:电子钟;时钟日历芯片;AT89S52

1

陈薪羽:带日历电子钟的设计

The Design and Implementation of Electron Clock

— The Design of the Hardware

Abstract

The monolithic computer is a monolithic microcomputer, be one kind of integrated circuit

chip, be that the width demonstrating drive circuit , pulse modulates breadboarding adopt the grand scale IC technology central authority processor CPU , random memory RAM , god of the earth read memory ROM , diversified I/O mouths and function (possibility such as interruption system , timer/ calculagraph having a data-handling capacity to be included, multi-path converter, A/D converter and so on circuit) integrated arrive at a piece of silicon slice upper formation one small but perfect computer system. Its volume is small , cost is low , the function is strong, apply to the intelligence product and the industrial automation broadly go ahead. But, 51 monolithic machine are that every representative and a kind of having representativeness most in monolithic machine. Design that being to realize one but to demonstrate the clock/ calendar regularly mainly, as well as electronic clock having noisy bell the regular time time.

The electronic clock is to electronize , digitize mainly make use of electron technology with the clock , own the clock is accurate , volume is small , the interface is amicable , expansion the function waits for a characteristic by force , the quilt applies to life and the job broadly middle. Require that the electron clock has multifunctional also often in besides, giving birth to a child in life and industry and agriculture.

Design that the chip applying AT89S52 is core , LCD liquid crystal display , uses the DS1302 real time clock calendar chip to accomplish fundamental clock/ calendar function originally. This realization method merit is that the circuit is simple , the function is reliable , real time nature is good , time accuracy is high , the simplicity , the programming are easy to handle.

That electronic clock is not bad apply to also may bring about more going to the lavatory by refitting , improving the function , life and job increasing the new function , giving people's thereby in the same life and job.

Key words:electronic clock; DS1302; AT89S52

2

华东交通大学毕业设计

目 录

摘 要 ..................................................................................................................... 1 ABSTRACT .............................................................................................................. 2 第一章 引 言 ......................................................................................................... 6 1.1 多功能电子时钟研究的背景和意义 ............................................................. 6 1.2 电子时钟的功能 ............................................................................................. 6 第二章 电子时钟设计方案分析 ........................................................................... 8 2.1 FPGA设计方案............................................................................................. 8 2.2 NE555时基电路设计方案 ........................................................................... 8 2.3 单片机设计方案 ............................................................................................. 9 第三章 电子时钟硬件设计 ................................................................................. 10 3.1 单片机特点 ................................................................................................... 10 3.2元器件选择 .................................................................................................... 10 3.2.1微处理器选择 .......................................................................................... 10 3.2.2 DS1302的片内寄存器 ............................................................................ 14 3.3电子时钟硬件电路设计 ................................................................................ 15 3.3.1 晶振电路设计 ......................................................................................... 16 3.3.2 复位电路设计 ....................................................................................... 17 3.3.3 按键电路设计 ....................................................................................... 18 3.3.4 显示电路设计 ......................................................................................... 19 3.3.4 时钟电路设计 ......................................................................................... 20

3

陈薪羽:带日历电子钟的设计

3.3.5 闹铃电路设计 ......................................................................................... 21 第三章 电子时钟软件设计 ................................................................................... 23 4.1主程序设计 .................................................................................................... 23 4.2 子程序设计 ................................................................................................... 23 4.2.1 实时时钟日历子程序设计 ..................................................................... 23 4.2.2 显示子程序设计 ..................................................................................... 24 4.2.3 键盘扫描子程序 ..................................................................................... 24 4.2.4 闹铃子程序设计 ..................................................................................... 24 第五章 系统调试 ................................................................................................. 28 5.1 硬件调试 ....................................................................................................... 28 5.1.1 单片机基础电路调试 ............................................................................. 28 5.1.2 DS1302电路调试 .................................................................................... 29 5.1.3 按键电路调试 ......................................................................................... 29 5.2 软件调试 ....................................................................................................... 29 5.2.1 键盘子程序调试 ..................................................................................... 30 结 论 ..................................................................................................................... 31 致 谢 ..................................................................................................................... 32 参考文献 ................................................................................................................. 33 附录A 程序 ......................................................................................................... 34 附录B 带日历电子钟元器件一览表 ................................................................. 44

4

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4