资源描述
AT89C2051Author:Yuan Zhenming,Zhang Liang,Zhan Guohua;From: http:/www.webCT.comAT89C2051 is made in the ATMEL Corporation, which is the low-voltage, high-performance CMOS8-bit microcontroller,Tablets containing repeated 2k bytes of program memory erasable read-only (PEROM) and random 128bytes data memory (RAM), device using ATMELs high density, non-volatile memory technology, Compatible with the standard of MCS-51 instruction set, built-chip 8-bit general-purpose central processing unit and repeatedly write the Flash memory, which can effectively reduce the development costs. AT89C2051 features a powerful single-chip can provide cost-effective in many Applications.Main features:Compatible the MCS51 command system;Contains the 2KB memory re-programming FLASH (1000);2.7 6V voltage range;the whole Static work: 0Hz 24KHz;Secrets 2 Program Memory Lock128 8-bit internal RAM15 programmable I / O linesTwo 16-bit timer / counter6 interrupt sources, two external interrupt sourcesProgrammable Serial ChannelHigh Precision Voltage Comparator (P1.0,P1.1,P3.6);Have the output port of the LED direct drive Low-power idle and power-down mode The pin Picture of AT89C2051Picture one the pin of AT89C2051AT89C2051s functional description:VCC: Power Supply VoltageGND: land P1 port: P1 mouth is a group of 8-bit bi-directional I / O interface, P1.2 P1.7 provide internal pull-up resistor,P1.0 and P1.1 internal supreme pull-up resistor. P1 mouth output buffer can absorb the current 20mA and direct-drive LED.When Programming and calibration, P1 mouth as the eighth address receive.P3 mouth: P3 port P3.0 P3.5, P3.7 is the internal pull-up resistor with the seven bi-directional I / O interface. Did not bring out the P3.6,It as a generic I / O port, but can not visit. Can be used as a fixed-chip input comparator output signal. when P3 write 1, they were highed the internal pull-up resistor can be raised as an input port.P3 port special function as shown in table 1:Table 1 P3 mouths special features引脚功能特性P3.0RXD (串行输入口)P3.1TXD (串行输出口)P3.2 (外中断0)P3.3 (外中断1)P3.4T0 (定时/计数器0外部输入)P3.5T1 (定时/计数器1外部输入)RST:Reset output. When the oscillator device reset, RST pin to maintain the high level of two machine cycle time.XTAL1: the RP-oscillator amplifier and internal clock generator input.TimerOverview of the Timer 89C2051 single-chip-chip has two 16-bit timer / counter, That is the timer 0 (T0) and Timer 1 (T1). They all have from time to time and event count function, Can be used for timing control, delay of external events, such as counting and testing occasions. Timers T0 and T1 two 16-bit timers in fact is 16-bit counter plus 1. Among them, T0 compositioned by the two 8-bit special function registers TH0 and TL0; T1 posed by the TH1 and TL1. These functions were controled by the special function registers TMOD and TCON When set to the work in the timing, Through the pin count of the external pulse signal. When the input pulse signal generated by the falling edge of 1-0, The value of timer plus 1. At of every machine cycle during the S5P2 sampling pin T0 and T1 the input level, if a machine cycle before sample value of 1, The next machine cycle sampling value is 0, The counter plus 1. Since then during S3P1 of the machine cycle, New value will into the counter.so Detection of a 1-0 transition of the two machine cycles,So The maximum count frequency of oscillation frequency of 1 / 24. In addition to the option of work from time to time or count,Each timer / counter have four kinds of work mode, That is, each of timer circuit kinds of four constitute a structural modelTwo low-power modeIdle modeIn idle mode, CPU to maintain sleep and all-chip peripherals remain active, this way generated in Software, At this point, Chip RAM and all the contents of special function registers remain unchanged. Idle mode was terminated by any interrupt request permission to or hardware reset.P1.0 and P1.1 ,in the non-use of external pull-up resistor on the case should be set to 0, Or in the use of pull-up resistor is set to 1.It should be noted that: when uses of hardware reset Termination idle mode, AT89C2051 is usually stopped from the program until the internal reset control of the two machine cycles before the restore procedure Service. In this case the hardware within the prohibition of the reading and writing of internal RAM, However, to allow access to ports, To eliminate the Hardware reset in the idle mode of port accidents may write, In principle, to enter the idle mode of instruction should not be under the command of a pin or an external memory port for a visit.Power-down modeIn power-down mode, the oscillator to stop working, enter the power-down mode ,Instructions, who was the last one, the implementation of the Directive, Chip RAM and all the contents of special function registers the termination of the previous power-down mode be frozen. To withdraw from power-down mode is the only way to reset the hardware, Reset will redefine all the Special Function Registers but Does not change the contents of RAM before the the Vcc work returned to normal levels Shall be null and void and must be reset to maintain a certain period of time in order to restart and oscillator stabilityP1.0 and P1.1 in the non-use of external pull-up resistor on the case should be set to 0, Or in the use of pull-up resistor is set to 1.OscillatorOscillator connected clientXTAL1: RP-oscillator amplifier and internal clock generator inputXTAL2: RP-oscillator amplifier outputCharacteristics of Oscillator XTAL1, XTAL2 ware the RP-chip oscillator amplifier inputs and outputs, Quartz crystal can be composed of the clock oscillator or ceramic oscillator, For more information from the external input clock driver AT89C2051, XTAL1 input clock signal from, XTAL2 should be left vacant.As the input to the internal circuit is a 2-flip-flop, Therefore, the external clock signal input without special requirements, However, it must comply with the maximum level and minimum norms and timingAT89C2051作者:Yuan Zhenming, Zhang Liang, Zhan Guohua;来自:http:/www.webCT.comAT89C2051是美国ATMEL公司生产的低电压、高性能CMOS8位单片机,片内含2k bytes的可反复擦写的只读程序存储器(PEROM)和128bytes的随机数据存储器(RAM),器件采用ATMEL公司的高密度、非易失性存储技术生产,兼容标准MCS-51指令系统,片内置通用8位中央处理器和可反复擦写的Flash存储器,可有效地降低开发成本。功能强大AT89C2051单片机可提供许多高性价比的应用场合。3.2主要功能特性: *兼容MCS51指令系统;*2KB可重编程FLASH存储器(1000次);*2.76V电压范围;*全静态工作:0Hz24KHz;*2级程序存储器保密锁定;* 1288位内部RAM;*15条可编程I/O线; *两个16位定时器/计数器;*6个中断源,两个外部中断源;*可编程串行通道;*高精度电压比较器(P1.0,P1.1,P3.6); *直接驱动LED的输出端口;*低功耗空闲和掉电模式AT89C2051的管脚引脚图如图2所示。 图1 AT89C2051封装管脚引脚图AT89C2051引脚功能说明:VCC:电源电压GND:地P1口:P1口是一组8位双向I/O接口,P1.2P1.7提供内部上拉电阻,P1.0和P1.1内部无上拉电阻。P1口输出缓冲器可吸收20mA的电流并可直接驱动LED。编程和校验时, P1口作为第八位地址接收。P3口:P3口的P3.0P3.5、P3.7是带有内部上拉电阻的7个双向I/O接口。P3.6没有引出,它作为一个通用的I/O口,但是不可访问。可作为固定输入的片内比较器的输出信号。当P3口写入1时,它们被内部的上拉电阻拉高并可作为输入端口。P3口的特殊功能如表1所示:RST:复位输出。当振荡器复位器件时,要保持RST脚两个机器周期的高电平时间。XTAL1:振荡器的反相放大器及内部时钟发生器的输入端。XTAL2:振荡器反相放大器的输出端。表1 P3口的特殊功能引脚功能特性P3.0RXD (串行输入口)P3.1TXD (串行输出口)P3.2 (外中断0)P3.3 (外中断1)P3.4T0 (定时/计数器0外部输入)P3.5T1 (定时/计数器1外部输入)定时器定时器概述89C2051单片机片内有两个16位定时器/计数器,即定时器0(T0)和定时器1(T1)。它们都有定时和事件计数功能,可用于定时控制、延时、对外部事件计数和检测等场合。定时器T0和T1两个16位定时器实际上都是16位加1计数器。其中,T0由两个8位特殊功能寄存器TH0和TL0构成;T1由TH1和TL1构成。这些功能都由特殊功能寄存器TMOD和TCON所控制。 设置为定时工作方式时,定时器计数AT89C2051片内振荡器输出的经12分频后的脉冲,即每个机器周期使定时器的数值加1直至计满溢出。当AT89C205采用12MHz晶振时,一个机器周期为1s,计数频率为1MHz。设置为计数工作方式时,通过引脚对外部脉冲信号计数。当输入脉冲信号产生由1至0的下降沿时,定时器的值加1。在每个机器周期的S5P2期间采样T0和T1引脚的输入电平,若前一个机器周期采样值为1,下一个机器周期采样值为0,则计数器加1。此后的机器周期S3P1期间,新的数值装入计数器。所以,检测一个1至0的跳变需要两个机器周期,故最高计数频率为振荡频率的1/24。除了可以选择定时或计数工作方式外,每个定时器/计数器还有4种工作模式,也就是每个定时器可构成4种电路结构模式。两种低功耗模式空闲模式 在空闲模式下,CPU保持睡眠状态而所有片内的外设仍保持激活状态,这种方式有软件产生。此时,片内RAM和所有特殊功能寄存器的内容保持不变。空闲模式可由任何允许的中断请求或者硬件复位终止。 P1.0和P1.1在不使用外部上拉电阻的情况下应设置为“0”,或者在使用上拉电阻的情况下设置为“1”。应注意的是:在用硬件复位终止空闲模式时,AT89C2051通常从程序停止一直到内部复位获得控制之前的两个机器周期处回复程序执行。在这种情况下片内硬件禁止对内部RAM的读写,但允许对端口的访问,要消除硬件复位终止空闲模式对端口意外写入的可能,原则上进入空闲模式指令的下一条指令不应对端口引脚或外部存储器进行访问。掉电模式在掉电模式下,振荡器停止工作,进入掉电模式的指令是最后一条被执行的指令,片内RAM和所有特殊功能寄存器的内容在终止掉电模式前被冻结。退出掉电模式的唯一方法是硬件复位,复位后将重新定义全部特殊功能寄存器但不改变RAM中的内容在Vcc恢复到正常工作电平前,复位应无效且必须保持一定时间以使振荡器重启动并稳定工作。P1.0和P1.1在不使用外部上拉电阻的情况下应设置为“0”,或者在使用上拉电阻的情况下设置为“1”。振荡器-振荡器连接端XTAL1:振荡器反相放大器以及内部时钟发生器的输入端XTAL2:振荡器反相放大器的输出端振荡器特征XTAL1、XTAL2为片内振荡器的反相放大器的输入和输出端,如图3所示。可采用石英晶体或者陶瓷振荡器组成时钟振荡器,如需从外部输入时钟驱动AT89C2051,时钟信号从XTAL1输入,XTAL2应悬空。由于输入到内部电路是经过一个2分频触发器,所以输入的外部时钟信号无需特殊要求,但它必须符合电平的最大和最小值及时序规范。
展开阅读全文