《基于单片机数字时钟设计开题报告.doc》由会员分享,可在线阅读,更多相关《基于单片机数字时钟设计开题报告.doc(20页珍藏版)》请在三一办公上搜索。
1、毕业设计(论文)材料之二(2)本科毕业设计(论文)开题报告题目: 基于单片机数字时钟设计The Design of Digital Clock Based On A Singlechip课 题 类 型:设计实验研究 论文 学 生 姓 名: 专 业 班 级: 学 号: 教 学 单 位: 指 导 教 师: 开 题 时 间: 2013年 月 日2013年 月 日一、 毕业设计(论文)内容及研究意义(价值)1.设计(论文)内容本论文主要研究基于单片机的数字时钟设计。当程序执行后,显示计时时间。设置4个操作键:K1:设置键;K2:上调键;K3:下调键;K4:确定键。电子钟的格式为:XX.XX.XX,由左
2、向右分别为:时、分、秒。完成显示由秒01一直加1至59,再恢复为00;分加1,由00至01,一直加1至59,再恢复00;时加1,时由00加至23之后秒、分、时全部清清零。该钟使用T0作250us的定时中断。走时调整:走时过程中直接调整且不影响走时准确性,按下时间选择键对“时、分、秒”显示进行调整,每按一下时间加,即加1,时间减,即减1。附加功能:星期,年、月、日,温度检测。本设计的主要内容:1、了解单片机技术的背景及发展现状,熟悉数字时钟各模块的工作原理;2、选择适当的芯片和元器件,确定系统电路,绘制电路原理图,尤其是各接口电路;3、熟悉单片机使用方法和C语言的编程规则,编写出相应模块的应用程
3、序;4、分别在各自的模块中调试出对应的功能,在Proteus软件上进行仿真。2. 研究意义及价值 20世纪末,电子技术获得了飞速的发展,在其推动下,现代电子产品几乎渗透了社会的各个领域,有力地推动了社会生产力的发展和社会信息化程度的提高,同时也使现代电子产品性能进一步提高,产品更新换代的节奏也越来越快。 时间对人们来说总是那么宝贵,工作的忙碌性和繁杂性容易使人忘记当前的时间。忘记了要做的事情,当事情不是很重要的时候,这种遗忘无伤大雅。但是,一旦重要事情,一时的耽误可能酿成大祸。目前,单片机正朝着高性能和多品种方向发展趋势将是进一步向着CMOS化、低功耗、小体积、大容量、高性能、低价格和外围电路
4、内装化等几个方面发展。下面是单片机的主要发展趋势。单片机应用的重要意义还在于,它从根本上改变了传统的控制系统设计思想和设计方法。从前必须由模拟电路或数字电路实现的大部分功能,现在已能用单片机通过软件方法来实现了。这种软件代替硬件的控制技术也称为微控制技术,是传统控制技术的一次革命。单片机模块中最常见的是数字钟,数字钟是一种用数字电路技术实现时、分、秒计时的装置,与机械式时钟相比具有更高的准确性和直观性,且无机械装置,具有更更长的使用寿命,因此得到了广泛的使用数字钟是采用数字电路实现对.时,分,秒.数字显示的计时装置,广泛用于个人家庭,车站,码头办公室等公共场所,成为人们日常生活中不可少的必需品
5、,由于数字集成电路的发展和石英晶体振荡器的广泛应用,使得数字钟的精度,远远超过老式钟表, 钟表的数字化给人们生产生活带来了极大的方便,而且大大地扩展了钟表原先的报时功能。诸如定时自动报警、按时自动打铃、时间程序自动控制、定时广播、自动起闭路灯、定时开关烘箱、通断动力设备甚至各种定时电气的自动启用等,所有这些,都是以钟表数字化为基础的。因此,研究数字钟及扩大其应用,有着非常现实的意义。二、 毕业设计(论文)研究现状和发展趋势(文献综述) 目前单片机渗透到我们生活的各个领域,几乎很难找到哪个领域没有单片机的踪迹。导弹的导航装置,飞机上各种仪表的控制,计算机的网络通讯与数据传输,工业自动化过程的实时
6、控制和数据处理,广泛使用的各种智能IC卡,录像机、摄像机,以及程控玩具、电子宠物等等,这些都离不开单片机。更不用说自动控制领域的机器人、智能仪表、医疗器械了。因此,单片机的学习、开发与应用将造就一批计算机应用与智能化控制的科学家、工程师。单片机在多功能数字钟中的应用已是非常普遍的,人们对数字钟的功能及工作顺序都非常熟悉。但是却很少知道它的内部结构以及工作原理。由单片机作为数字钟的核心控制器,可以通过它的时钟信号进行时实现计时功能,将其时间数据经单片机输出,利用显示器显示出来。通过键盘可以进行定时、校时功能。输出设备显示器可以用液晶显示技术和数码管显示技术。三、 毕业设计(论文)研究方案及工作计
7、划(含工作重点与难点及拟采用的途径)1、研究方案 本设计采用型号为AT89C52的单片机。器件采用ATMEL公司的高密度、非易失性存储技术生产,兼容标准MCS-52指令系统,片内置通用8位中央处理器和Flash存储单元,采用7段LED 数码管显示时、分、秒,以24小时计时方式,根据数码管动态显示原理来进行显示,用12MHz 的晶振产生振荡脉冲,定时器计数。 2、工作重点与难点本次设计的单片机数字时钟系统中,其难点主要来源包括晶体频率误差,定时器溢出误差,延迟误差的降低。晶体频率产生震荡,容易产生走时误差;定时器溢出的时间误差,本应这一秒溢出,但却在下一秒溢出,造成走时误差;延迟时间过长或过短,
8、都会造成与基准时间产生偏差,造成走时误差。因此,在选用芯片、器件、硬件时注意它们的性能优劣;烧入程序后,LED液晶显示屏不显示或者亮度不好。不显示时首先使用万用表对电路进行测试,观察是否存在漏焊,虚焊,或者元件损坏的现象。若无此问题查看烧写的程序是否正确无误,对程序进行认真修改。当显示亮度不好时一遍旋转10K欧的滑动变阻器,一遍观看LED显示屏,直到看到合适的亮度为止。经过多次的反复调试试与分析,可以对电路的原理及功能更加熟悉,同时提高了设计能力与及对电路的分析能力。3、工作计划起止日期(日/月)周次内 容 进 程备 注1.7-2.24接受设计的课题,查找相关参考文献和资料熟悉设计的课题,查阅
9、、整理参考文献和资料。学习相关参考文献和资料。2.253.101-2撰写开题报告,开题答辩,对设计课题的方案作初步论证3.114.73-6方案论证,软件编程及仿真4.85.57-10熟悉毕业论文格式,撰写论文初稿5.65.1911-12完成论文初稿,提交论文初稿5.206.1613-16修改毕业论文,总体完善6.176.2317完成论文终稿,提交论文终稿,参加论文答辩四、主要参考文献(不少于10篇,期刊类文献不少于7篇,应有一定数量的外文文献,至少附一篇引用的外文文献(3个页面以上)及其译文)1王法能. 单片机原理及应用M. 科学出版社,20042 陈 宁. 单片机技术应用基础M. 南京:南京
10、信息职业技术学院, 20053 刘 勇. 数字电路 M. 电子工业出版社, 20054 杨子文. 单片机原理及应用M. 西安电子科技大学出版社2006 5岂兴明,唐杰等 .51单片机编程基础与开发实例详解M. 人民邮电出版社,2008 6 张毅刚. 新编MCS-51单片机应用设计M. 哈尔滨: 哈尔滨工业大学出版社, 2003 7 朱定华,等. 单片微机原理与应用M. 北京: 北京清华大学出版社, 北京:北京交通大学出版,20038 Ling Zhenbao, Wang Jun, Qiu Chunling. Study of Measurement for the Anomalous Soli
11、d MatterC. The Sixth International Conference on Measurement and Control of Granular Materials.2003:181-184.9 8-bit Microcontroller With 8K Bytes in-system programble Flash AT89S52. ATMEL, 2001.10 8-bit Microcontroller With 20K Bytes Flash AT89C55WD.ATMEL,2000.11 期刊: ISSN 1009-623X . 单片机与嵌入式系统应用 北京:
12、 北京航空航天大学,2001附英文文献及译文8-bit Microcontroller With 8K Byte Flash AT89C52FeaturesCompatible with MCS-51 Products8K Bytes of In-System Reprogrammable Flash MemoryEndurance: 1,000 Write/Erase CyclesFully Static Operation: 0 Hz to 24 MHzThree-level Program Memory Lock256 x 8-bit Internal RAM32 Programmabl
13、e I/O LinesThree 16-bit Timer/CountersEight Interrupt SourcesProgrammable Serial ChannelLow-power Idle and Power-down ModesDescriptionThe AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufac
14、tured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 and 80C52 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatil
15、e 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.Pin ConfigurationsBlock DiagramPin DescriptionVCCSupply voltage.GNDGround.Port 0Port 0 is an 8-bit open drain
16、bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs. Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In th
17、is mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes during program verification. External pull-ups are required during program verification.Port 1Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 outpu
18、t buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 c
19、an be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1 also receives the low-order address bytes during Flash programming and verification. Port 2Port 2 is an 8-bit bi-directio
20、nal I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because o
21、f the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memories that use 16-bit addresses (MOVX DPTR). In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external d
22、ata memories that use 8-bit addresses (MOVX RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification.Port 3Port 3 is an 8-bit bi-directional I/O port with internal pull-ups.
23、 The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups.Port 3 also serves th
24、e functions of various special features of the AT89C51, as shown in the following table. Port 3 also receives some control signals for Flash programming and verification.RSTReset input. A high on this pin for two machine cycles while the oscillator is running resets the device.ALE/Address Latch Enab
25、le is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input () during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clock
26、ing purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Set
27、ting the ALE-disable bit has no effect if the microcontroller is in external execution mode.Program Store Enable is the read strobe to external program memory. When the AT89C52 is executing code from external program memory, is activated twice each machine cycle, except that two activations are skip
28、ped during each access to external data memory./VPPExternal Access Enable. must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, will be internally latched on reset. E
29、A should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP ) during Flash programming when 12-volt programming is selected.XTAL1Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2Outp
30、ut from the inverting oscillator amplifier.Special Function RegistersA map of the on-chip memory area called the Special Function Register (SFR) space is shown in the Table 1.Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses t
31、o these addresses will in general return random data, and write accesses will have an indeterminate effect. User software should not write 1s to these unlisted locations, since they may be used in future products to invoke new features. In that case, the reset or inactive values of the new bits will
32、 always be 0.Timer 2 Registers Control and status bits are contained in registers T2CON and T2MOD for Timer 2. The register pair (RCAP2H, RCAP2L) are the Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.Interrupt Registers The individual interrupt enable bits ar
33、e in the IE register. Two priorities can be set for each of the six interrupt sources in the IP register.Data MemoryThe AT89C52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a parallel address space to the Special Function Registers. That means the upper 128 bytes have the same add
34、resses as the SFR space but are physically separate from SFR space.When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions that use direct addressing acc
35、ess SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H .MOV 0A0H, #dataInstructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data
36、 byte at address 0A0H, rather than P2 (whose address is 0A0H).MOV R0, #dataNote that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.Timer 0 and 1Timer 0 and Timer 1 in the AT89C52 operate the same way as Timer 0 and Timer 1 in th
37、e AT89C51.Timer 2Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The type of operation is selected by bit C/T2 in the SFR T2CON.Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by
38、bits in T2CON, as shown in Table 3.Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscillator frequency.In the Counter function, th
39、e register is incremented in response to a 1-to-0 transition at its corresponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count
40、 value appears in the register during S3P1 of the cycle following the one in which the transition was detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. To ensure that a given level is
41、sampled at least once before it changes, the level should be held for at least one full machine cycle.Capture ModeIn the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON.This bit can then be use
42、d to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same operation, but a 1-to-0 transition at external input T2EX also causes the current value in TH2 and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the transition at T2EX causes bit EXF2 in T2CON to be set. The
43、EXF2 bit, like TF2 can generate an interrupt. The capture mode is illustrated in Figure 1.Auto-reload (Up or Down Counter)Timer 2 can be programmed to count up or down when configured in its 16-bit auto-reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the SFR T2M
44、OD. Upon reset, the DCEN bit is set to 0 so that timer 2 will default to count up. When DCEN is set, Timer 2 can count up or down, depending on the value of the T2EX pin.Figure 2 shows Timer 2 automatically counting up when DCEN = 0. In this mode, two options are selected by bit EXEN2 in T2CON. If E
45、XEN2 = 0, Timer 2 counts up to 0FFFFH and then sets the TF2 bit upon overflow. The overflow also causes the timer registers to be reloaded with the 16-bit value in RCAP2H and RCAP2L. The values in Timer in Capture ModeRCAP2H and RCAP2L are preset by software. If EXEN2 = 1, a 16-bit reload can be tri
46、ggered either by an overflow or by a 1-to-0 transition at external input T2EX. This transition also sets the EXF2 bit. Both the TF2 and EXF2 bits can generate an interrupt if enabled. Setting the DCEN bit enables Timer 2 to count up or down, as shown in Figure 3. In this mode, the T2EX pin controls
47、the direction of the count. A logic 1 at T2EX makes Timer 2 count up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also causes the 16-bit value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2, respectively. A logic 0 at T2EX makes Timer 2 count down.
48、 The timer underflows when TH2 and TL2 equal the values stored in RCAP2H and RCAP2L. The underflow sets the TF2 bit and causes 0FFFFH to be reloaded into the timer registers. The EXF2 bit toggles whenever Timer 2 overflows or underflows and can be used as a 17th bit of resolution. In this operating mode, EXF2 does not flag an interrupt.文献译文: