基于51单片机的数字时钟设计_毕业设计 下载本文

基于51单片机的数字时钟设计

目 录

摘 要 ............................................................................................................................................................ 1 Abstract ......................................................................................................................................................... 2 第一章 绪论 .................................................................................................................................................. 3

1.1 数字时钟设计的背景 ..................................................................................................................... 3 第二章 AT89C51单片机简介 ..................................................................................................................... 3

2.1 单片机介绍 .................................................................................................................................... 3 2.2 单片机的应用特点 ......................................................................................................................... 4 2.3 单片机的应用领域 ......................................................................................................................... 4 2.4 单片机的中断与定时系统 ............................................................................................................. 4

2.4.1 MCS-51单片机中断系统 .................................................................................................. 4 2.4.2 MCS-51 单片机的定时器/计数器 ................................................................................... 6 2.4.3 MCS-51定时器/计数器的四种工作方式 .......................................................................... 6 2.5 AT89C51引脚功能介绍 .................................................................................................................. 7 第三章 设计方案 .......................................................................................................................................... 8

3.1 主程序 ............................................................................................................................................ 8 3.2 数码管显示模块............................................................................................................................. 9 3.3 定时器计数器T0中断服务程序 ................................................................................................... 9 3.4按键处理模块................................................................................................................................ 10 第四章 硬件电路设计 ................................................................................................................................ 10

4.1 复位电路 ...................................................................................................................................... 10 4.2 时钟电路 .......................................................................................................................................11 4.3 按键电路 ...................................................................................................................................... 12 4.4 数码管显示电路........................................................................................................................... 13 4.5 电源电路设计............................................................................................................................... 13 第五章 软件设计与程序代码 .................................................................................................................... 14

5.1 软件选择与介绍........................................................................................................................... 14

5.1.1 软件介绍........................................................................................................................... 14 5.1.2 Proteus7.8的特点 .......................................................................................................... 15 5.2 软件仿真电路全图 ....................................................................................................................... 15 5.3 源程序代码 .................................................................................................................................. 16 第六章 结论 ................................................................................................................................................ 20 参考文献 ...................................................................................................................................................... 21 致谢 .............................................................................................................................................................. 22

- 1 -

摘 要 近几年,单片机在各个领域得到广泛的应用。从工业到人们的日常生活,大部分的科技产品都是通过单片机来控制。在它问世之前,自动控制设备得不到广泛的应用,这是因为控制设备的体积庞大,耗电量大,价格昂贵。在第一台微处理器成功研制不久,第一个单片机就问世了。因为其小巧的体积,低功耗,以及高效的性能,单片机受到了大家的欢迎。

本设计利用Atmel公司的AT89C52单片机对电子时钟进行开发,设计了实现所需功能的硬件电路,应用C语言进行软件编程,并用Proteus软件进行演示、验证。主要介绍用单片机内部的定时/计数器来实现电子时钟的方法,本设计由单片机80C51芯片和LED数码管为核心,辅以必要的电路,构成了一个单片机的数字电子时钟。它的计时周期为24小时,显满刻度为“23时59分59秒”,且配有4个独立键盘,可以灵活地调节时间和日期,并具有一定的扩展性。

关键词:单片机,数字时钟,动态显示,LED数码管显示,独立按键

Abstract Single Chip Microcomputer has achieved a immemse popularity in all fileds in recent years.From industry to people’s common lives,most of technical applications are controlled by SCM. Before it appeared,the automatic devices could’t be widely used because of their huge size ,large quantity of power cost and high price.The first SCM appeared as soon as the first MCU(MicroController Unit) was successfully developed.Due to its small size,low power cost and high performance,it has been welcomed by people.

This design uses AT89C52 MCU to developing electronic clock, it has designed to achieve the required functionality of the hardware circuit, using the C to programming software, and using proteus to show. Describing the method to use the microcontroller's internal timer and counter to implement electronic clock, the design of the 80C51 MCU core chips and LED digital tube display, supplemented by the necessary circuitry to form a single-chip digital clock. Its time period is 24 hours, full scale is \and it is equipped with four independent keyboard, adjusting the time and date Flexible. It is also have some scalability.

Key words: Microcomputer; Digital clock; Dynamic display; LED digital tube display; Separate keyboard