AT89S51单片机中文资料
AT89S51单片机介绍

2007年12月11日星期二 08:45AT89C2051是精简版的51单片机,精简掉了P0口和P2口,只有20引脚,但其内部集成了一个很实用的模拟比较器,特别适合开发精简的51应用系统,毕竟很多时候我们开发简单的产品时用不了全部32个I/O口,用AT89C2051更合适,芯片体积更小,而且AT89C2051的工作电压最低为2.7V,因此可以用来开发两节5号电池供电的便携式产品。
本文以ATMEL公司生产的51系列家族的AT89S51和AT89C2051两种单片机来讲解,两种单片机是目前最常用的单片机,其中AT89S51为标准51单片机,当然其功能比早期的51单片机更强大,支持ISP在系统编程技术,内置硬件看门狗。
一、AT89S51单片机引脚介绍AT89S51有PDIP、PLCC、TQFP三种封装方式,其中最常见的就是采用40Pin封装的双列直接PDIP封装,外形结构下图。
芯片共有40个引脚,引脚的排列顺序为从靠芯片的缺口(见右图)左边那列引脚逆时针数起,依次为1、2、3、4。
40,其中芯片的1脚顶上有个凹点(见右图)。
在单片机的40个引脚中,电源引脚2根,外接晶体振荡器引脚2根,控制引脚4根以及4组8位可编程I/O引脚32根。
1、主电源引脚(2根)VCC(Pin40):电源输入,接+5V电源GND(Pin20):接地线2、外接晶振引脚(2根)XTAL1(Pin19):片内振荡电路的输入端XTAL2(Pin20):片内振荡电路的输出端3、控制引脚(4根)RST/VPP(Pin9):复位引脚,引脚上出现2个机器周期的高电平将使单片机复位。
ALE/PROG(Pin30):地址锁存允许信号PSEN(Pin29):外部存储器读选通信号EA/VPP(Pin31):程序存储器的内外部选通,接低电平从外部程序存储器读指令,如果接高电平则从内部程序存储器读指令。
4、可编程输入/输出引脚(32根)AT89S51单片机有4组8位的可编程I/O口,分别位P0、P1、P2、P3口,每个口有8位(8根引脚),共32根。
AT89S51系列单片机的特点(AT89S51引脚功能及应用电路)

AT89S51系列单片机的特点(AT89S51引脚功能及应用电路)AT89S51概述AT89S51是一个低功耗,高性能CMOS 8位单片机,片内含4k Bytes ISP(In-system programmable)的可反复擦写1000次的Flash只读程序存储器,器件采用ATMEL公司的高密度、非易失性存储技术制造,兼容标准MCS-51指令系统及80C51引脚结构,芯片内集成了通用8位中央处理器和ISP Flash存储单元,AT89S51在众多嵌入式控制应用系统中得到广泛应用。
AT89S51性能参数1、4k Bytes Flash片内程序存储器;
2、128 bytes的随机存取数据存储器(RAM);
3、32个外部双向输入/输出(I/O)口;
4、2个中断优先级、2层中断嵌套中断;
5、5个中断源;
6、2个16位可编程定时器/计数器;
7、1个全双工串行通信口;
8、看门狗(WDT)电路;
9、片内振荡器和时钟电路;
10、与MCS-51兼容;
11、全静态工作:0Hz-33MHz;
12、三级程序存储器保密锁定;
13、可编程串行通道;
14、低功耗的闲置和掉电模式。
AT89S51引脚及功能VCC:电源电压输入端。
GND:电源地。
P0口:P0口为一个8位漏级开路双向I/O口,每脚可吸收8TTL门电流。
当P1口的管脚第一次写1时,被定义为高阻输入。
P0能够用于外部程序数据存储器,它可以被定义为数据/地址的低八位。
在FIASH编程时,P0 口作为原码输入口,当FIASH进行校验时,。
AT89S51单片机的认识和管脚功能

AT89S51单片机的认识和管脚功能AT89C51是一种带4K字节闪烁可编程可擦除只读存储器(FPEROM—Falsh Programmable and Erasable Read Only Memory)的低电压,高性能CMOS8位微处理器,俗称单片机。
该器件采用ATMEL 高密度非易失存储器制造技术制造,与工业标准的MCS-51指令集和输出管脚相兼容。
由于将多功能8位CPU和闪烁存储器组合在单个芯片中,ATMEL的AT89C51是一种高效微控制器,为很多嵌入式控制系统提供了一种灵活性高且价廉的方案。
图1是常用的一种单片机,型号为AT89S51,它将计算机的功能都集成到这个芯片内部去了,就这么一个小小的芯片就能构成一台小型的电脑,因此叫做单片机。
它有40个管脚,分成两排,每一排各有20个脚,其中左下角标有箭头的为第1脚,然后按逆时针方向依次为第2脚、第3脚……第40脚,如下图所示:在40个管脚中,其中有32个脚可用于各种控制,比如控制小灯的亮与灭、控制电机的正转与反转、控制电梯的升与降等,这32个脚叫做单片机的“端口”,在单片机技术中,每个端口都有一个特定的名字,比如第一脚的那个端口叫做“P1.0”,由于本次试验仅仅控制一个小灯的亮与灭,由此只用一个端口就行了,我们就用第一脚的P1.0端口吧,如下图所示:1.主要特性:·与MCS-51 兼容·4K字节可编程闪烁存储器寿命:1000写/擦循环数据保留时间:10年·全静态工作:0Hz-24Hz·三级程序存储器锁定·128*8位内部RAM·32可编程I/O线·两个16位定时器/计数器·5个中断源·可编程串行通道·低功耗的闲置和掉电模式·片内振荡器和时钟电路2.管脚说明:VCC:供电电压。
GND:接地。
P0口:P0口为一个8位漏级开路双向I/O口,每脚可吸收8TTL 门电流。
主控芯片AT89S51

主控芯片AT89S51单片机AT89S51功能介绍AT89S51是一种带4K字节闪烁可编程可擦除只读存储器(FPEROM—FalshProgrammable and Erasable Read Only Memory)的低电压,高性能CMOS8位微处理器,俗称单片机。
该器件采用ATMEL高密度非易失存储器制造技术制造,与工业标准的MCS-51指令集和输出管脚相兼容。
由于将多功能8位CPU和闪烁存储器组合在单个芯片中,ATMEL的AT89S51是一种高效微控制器,为很多嵌入式控制系统提供了一种灵活性高且价廉的方案,AT89S51芯片引脚图如图2-1所示。
主要特性:·与MCS-51 兼容·4K字节可编程闪烁存储器Array·寿命:1000写/擦循环·数据保留时间:10年·全静态工作:0Hz-24Hz·三级程序存储器锁定·128*8位内部RAM·32可编程I/O线·两个16位定时器/计数器·5个中断源·可编程串行通道·低功耗的闲置和掉电模式·片内振荡器和时钟电路管脚说明:下面按其引脚功能分为四部分叙述这40条引脚的功能。
1、主电源引脚V SS和V SSAT89S51芯片引脚图V SS——(40脚)接+5V电压;V SS——(20脚)接地。
2、外接晶体引脚XTAL1和XTAL2XTAL1(19脚)接外部晶体的一个引脚。
在单片机内部,它是一个反相放大器的输入端,这个放大器构成了片内振荡器。
当采用外部振荡器时,对HMOS单片机,此引脚应接地;对SHMOS单片机,此引脚作为驱动端。
XTAL2(18脚)接外晶体的另一端。
在单片机内部,接至上述振荡器的反相放大器的输出端。
采用外部振荡器时,对HMOS单片机,该引脚接外部振荡器的信号,即把外部振荡器的信号直接接到内部时钟发生器的输入端;对XHMOS,此引脚应悬浮。
AT89S51单片机简介复习过程

A T89S51单片机简介一、AT89S51单片机简介AT89S51 为 ATMEL 所生产的可电气烧录清洗的 8051 相容单芯片,其内部程序代码容量为4KB(一)、AT89S51主要功能列举如下:1、为一般控制应用的 8 位单芯片2、晶片内部具时钟振荡器(传统最高工作频率可至 12MHz)3、内部程式存储器(ROM)为 4KB4、内部数据存储器(RAM)为 128B5、外部程序存储器可扩充至 64KB6、外部数据存储器可扩充至 64KB7、32 条双向输入输出线,且每条均可以单独做 I/O 的控制8、5 个中断向量源9、2 组独立的 16 位定时器Array10、1 个全多工串行通信端口11、8751 及 8752 单芯片具有数据保密的功能12、单芯片提供位逻辑运算指令(二)、AT89S51各引脚功能介绍:VCC:AT89S51 电源正端输入,接+5V。
VSS:电源地端。
XTAL1:单芯片系统时钟的反相放大器输入端。
XTAL2:系统时钟的反相放大器输出端,一般在设计上只要在 XTAL1 和 XTAL2 上接上一只石英振荡晶体系统就可以动作了,此外可以在两引脚与地之间加入一20PF 的小电容,可以使系统更稳定,避免噪声干扰而死机。
RESET:AT89S51的重置引脚,高电平动作,当要对晶片重置时,只要对此引脚电平提升至高电平并保持两个机器周期以上的时间,AT89S51便能完成系统重置的各项动作,使得内部特殊功能寄存器之内容均被设成已知状态,并且至地址0000H处开始读入程序代码而执行程序。
EA/Vpp:"EA"为英文"External Access"的缩写,表示存取外部程序代码之意,低电平动作,也就是说当此引脚接低电平后,系统会取用外部的程序代码(存于外部EPROM中)来执行程序。
因此在8031及8032中,EA引脚必须接低电平,因为其内部无程序存储器空间。
单片机第3章 AT89S51单片机原理与基本应用系统

2、内部数据存储器(内RAM)
AT89S51单片机内部有128B字节划分为三部分: 工作寄存器区、位寻址区和数据缓冲区。
30~7FH
数据 缓冲
区
位寻址 20~2FH 区
18~1FH 3区 10~17H 2区 08~0FH 1区 00~07H 0区 (R0~R7)
0区(00H~07H)
1区(08H~0FH)
2区(10H~17H)
3区(18H~1FH)
在任一时刻只有一个区作为当前的工作寄存器 区,相应的空间单元作为工作寄存器使用。工作寄 存器区的选择可通过程序状态字PSW中的D4、D3 位实现。不是当前工作寄存器区的可以作为一般的 RAM空间使用。
操作方式:8位整体操作。
二、AT89S51单片机引脚功能
1、电源 VCC(P40)——芯片电源,接+5V。 VSS(P20) ——接电源地。
2、时钟 XTAL1(P19)——晶体振荡电路的反相器
输入端 XTAL2(P18)——晶体振荡电路的反相器
输出端。
使用内部振荡电路时,该引脚外接石英晶 体和补偿电容。使用外部振荡输入时从 XTAL2输入,此时XTAL1需接地。
MOV指令操作 MOVX指令操作
RAM地址空间
1、程序存储器(ROM) 不管是内部的还是外部的ROM,开头的
0003H~002AH空间地址是中断源的入口地址区,是专 用单元,一般情况下用户不能用来存放其它程序。
CPU是根据PC(程序计数器)值从ROM中取指 令来执行的。CPU每从ROM中读取一个字节,自动执 行(PC)+1→PC,即PC指向下一个地址空间,一般 情况下CPU是按ROM地址空间顺序从小到大依次执行。 只有执行的指令是转移类指令,才根据转移类指令所指 示的新地址,调整PC值,然后根据新的PC值从对应的 地址空间中取指令来执行。
AT89S51单片机简介

AT89S51单⽚机简介⼀、AT89S51单⽚机简介AT89S51 为ATMEL 所⽣产的可电⽓烧录清洗的8051 相容单芯⽚,其内部程序代码容量为4KB (⼀)、AT89S51主要功能列举如下:1、为⼀般控制应⽤的8 位单芯⽚2、晶⽚内部具时钟振荡器(传统最⾼⼯作频率可⾄12MHz)3、内部程式存储器(ROM)为4KB4、内部数据存储器(RAM)为128B5、外部程序存储器可扩充⾄64KB6、外部数据存储器可扩充⾄64KB7、32 条双向输⼊输出线,且每条均可以单独做I/O 的控制8、5 个中断向量源9、2 组独⽴的16 位定时器10、1 个全多⼯串⾏通信端⼝11、8751 及8752 单芯⽚具有数据保密的功能12、单芯⽚提供位逻辑运算指令(⼆)、AT89S51各引脚功能介绍:VCC:Array AT89S51 电源正端输⼊,接+5V。
VSS:电源地端。
XTAL1:单芯⽚系统时钟的反相放⼤器输⼊端。
XTAL2:系统时钟的反相放⼤器输出端,⼀般在设计上只要在XTAL1 和XTAL2上接上⼀只⽯英振荡晶体系统就可以动作了,此外可以在两引脚与地之间加⼊⼀20PF 的⼩电容,可以使系统更稳定,避免噪声⼲扰⽽死机。
RESET:AT89S51的重置引脚,⾼电平动作,当要对晶⽚重置时,只要对此引脚电平提升⾄⾼电平并保持两个机器周期以上的时间,AT89S51便能完成系统重置的各项动作,使得内部特殊功能寄存器之内容均被设成已知状态,并且⾄地址0000H处开始读⼊程序代码⽽执⾏程序。
EA/Vpp:"EA"为英⽂"External Access"的缩写,表⽰存取外部程序代码之意,低电平动作,也就是说当此引脚接低电平后,系统会取⽤外部的程序代码(存于外部EPROM中)来执⾏程序。
因此在8031及8032中,EA引脚必须接低电平,因为其内部⽆程序存储器空间。
如果是使⽤8751 内部程序空间时,此引脚要接成⾼电平。
AT89S51单片机中文资料

1AT89S51是美国ATMEL 公司生产的低功耗,高性能CMOS8位单片机,片内含4k bytes 的可系统编程的Flash 只读程序存储器,器件采用ATMEL 公司的高密度、非易失性存储技术生产,兼容标准8051指令系统及引脚。
它集Flash 程序存储器既可在线编程(ISP )也可用传统方法进行编程及通用8位微处理器于单片芯片中,ATMEL 公司的功能强大,低价位AT89S51单片机可为您提供许多高性价比的应用场合,可灵活应用于各种控制领域。
主要性能参数:·与MCS-51产品指令系统完全兼容·4k 字节在系统编程(ISP )Flash 闪速存储器 ·1000次擦写周期·4.0-5.5V 的工作电压范围 ·全静态工作模式:0Hz -33MHz ·三级程序加密锁 ·128×8字节内部RAM ·32个可编程I /O 口线 ·2个16位定时/计数器 ·6个中断源·全双工串行UART 通道 ·低功耗空闲和掉电模式 ·中断可从空闲模唤醒系统 ·看门狗(WDT )及双数据指针 ·掉电标识和快速编程特性·灵活的在系统编程(ISP 字节或页写模式)2功能特性概述:A T89S51提供以下标准功能:4k 字节Flash 闪速存储器,128字节内部RAM ,32个I /O 口线,看门狗(WDT ),两个数据指针,两个16位定时/计数器,一个5向量两级中断结构,一个全双工串行通信口,片内振荡器及时钟电路。
同时,A T89S51可降至0Hz 的静态逻辑操作,并支持两种软件可选的节电工作模式。
空闲方式停止CPU 的工作,但允许RAM ,定时/计数器,串行通信口及中断系统继续工作。
掉电方式保存RAM 中的内容,但振荡器停止工作并禁止其它所有部件工作直到下一个硬件复位。
at89s51中文资料_数据手册_参数

XTAL2 10 XTAL1 11
GND 12 PWRGND 13 (A8) P2.0 14 (A9) P2.1 15 (A10) P2.2 16 (A11) P2.3 17 (A12) P2.4 18 (A13) P2.5 19 (A14) P2.6 20 (A15) P2.7 21
The AT89S51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a five-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next external interrupt or hardware reset.
单片机芯片AT89S51说明书-----外文文献译文和原文(可编辑)

DATASHEET OF AT89S518-bit microcontroller with 4k Bytes in-system programmable FlashBookmarks---Features---Description---Pin Configurations---Pin Description---Special Function Registers---Memory Organization---Watchdog Timer---Using the WDT---WDT during Power-down and Idle---UART---Timer 0 and 1---Interrupts---Oscillator Characteristics---Idle Mode---Power-down Mode---Program Memory Lock Bits---Programming the Flash Parallel Mode--- Programming the Flash Serial Mode--- Programming Interface Parallel Mode--- Flash Programming and Verification Characteristics Parallel Mode--- Flash Programming and Verification Waveforms Serial Mode--- Absolute imum Ratings--- DC Characteristics--- AC Characteristics--- External Program and Data Memory Characteristics--- External Program Memory Read Cycle--- External Data Memory Read Cycle--- External Data Memory Write Cycle--- External Clock Drive Waveforms--- External Clock Drive--- Serial Port Timing: Shift Register Mode Test Conditions--- Shift Register Mode Timing Waveforms--- AC Testing Input/Output Waveforms--- Float Waveforms--- Ordering Information--- Packaging InformationFeaturesCompatible with MCS -51Products4K Bytes of In-System Programmable ISP Flash Memory Endurance: 1000 Write/Erase Cycle 4.0V to 5.5V Operating RangeFully Static Operation: 0 Hz to 33 MHzThree-level Program Memory Lock128 x 8-bit Internal RAM32 Programmable I/O LinesTwo 16-bit Timer/CountersSix Interrupt SourcesFull Duplex UART Serial ChannelLow-power Idle and Power-down ModesInterrupt Recovery from Power-down ModeWatchdog TimerDual Data PointerPower-off FlagFast Programming TimeFlexible ISP Programming Byte and Page ModeDescriptionThe AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of In-System Programmable Flash memory. The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 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 versatile 8-bit CPU with In-System Programmable Flash on a monolithic chip, the Atmel AT89S51 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications.The AT89S51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a five-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes.The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next external interrupt or hardware reset. Pin ConfigurationsPin DescriptionVCC Supply voltage all packages except 42-PDIP .GND Ground all packages except 42-PDIP; for 42-PDIP GND connects only the logic core and the embedded program memory .VDD Supply voltage for the 42-PDIP which connects only the logic core and the embedded program memory.PWRVDD Supply voltage for the 42-PDIP which connects only the I/O Pad Drivers. The application board MUST connect both VDD and PWRVDD to the board supply voltage. PWRGND Ground for the 42-PDIP which connects only the I/O Pad Drivers. PWRGND and GND are weakly connected through the common silicon substrate, but not through any metal link. The application board MUST connect both GND and PWRGND to the board ground.Port 0 Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sinkeight 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 this 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 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output 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 I IL because of the internal pull-ups.Port 1 also receives the low-order address bytes during Flash programming and verification.Port 2 Port 2 is an 8-bit bi-directional 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 of the internal pull-ups.Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses MOVX @ DPTR . In this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory 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 3 Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. 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 receives some control signals for Flash programming and verification.Port 3 also serves the functions of various special features of the AT89S51, as shown in the following table.RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR address 8EH can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.ALE/PROG Address Latch Enable ALE 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 PROG during Flash programming.In normal operation, ALE is emitted at a constant rate of 1/6the oscillator frequency and may be used for external timing or clocking 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 b it set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN Program Store Enable PSEN is the read strobe to external program memory.When the AT89S51 is executing code from external program memory, PSEN is activatedactivations are skipped during each access twice each machine cycle, except that two PSEN to external data memory.EA/VPP External Access Enable. EA 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, EA will be internally latched on reset. EA should be strapped to Vcc for internal program executions. This pin also receives the 12-volt programming enable voltage Vpp during Flash programming.XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2 Output from the inverting oscillator amplifierSpecial Function Registers A map of the on-chip memory area called the Special Function Register SFR space is shown in Table 1.Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented on the chip. Read accesses to 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 always be 0.Interrupt Registers: The individual interrupt enable bits are in the IE register. Two priorities can be set for each of the five interrupt sources in the IP register.Power off Flag: The Power off Flag POF is located at bit 4 PCON.4 in the PCON SFR.POF is set to 1 during power up. It can be set and rest under software control and is not affected by reset.Memory Organization MCS-51 devices have a separate address space for Program and Data Memory. Up to 64K bytes each of external Program and Data Memory can be addressed. Program Memory If the EA pin is connected to GND, all program fetches are directed to external memory.On the AT89S51, if EA is connected to Vcc, program fetches to addresses 0000H through FFFH are directed to internal memory and fetches to addresses 1000H through FFFFH are directed to external memory.Data Memory The AT89S51 implements 128 bytes of on-chip RAM. The 128 bytes are accessible via direct and indirect addressing modes. Stack operations are examples of indirect addressing, so the 128 bytes of data RAM are available as stack space.Watchdog Timer The WDT is intended as a recovery method in situations where the CPU may be subjected to software upsets. The WDT consists of a 14-bit counter and the Watchdog Timer Reset WDTRST SFR. The WDT is defaulted to disable from exiting reset. To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register SFR location 0A6H .When the WDT is enabled, it will increment every machine cycle while the oscillator is running. The WDT timeout period is dependent on the external clock frequency. There is no way to disable the WDT except through reset either hardware reset or WDT overflow reset . When WDT overflows, it will drive an output RESET HIGH pulse at the RST pin.Using the WDT To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register SFR location 0A6H . When the WDT is enabled, the user needs to service it by writing 01EH and 0E1H to WDTRST to avoid a WDT overflow. The 14-bit counter overflows whenit reaches 16383 3FFFH , and this will reset the device. When the WDT is enabled, it will increment every machine cycle while the oscillator is running. This means the user must reset the WDT at least every 16383 machine cycles. To reset the WDT the user must write 01EH and 0E1H to WDTRST. WDTRST is a write-only register. The WDT counter cannot be read or written.附2 中文翻译单片机芯片AT89S51说明书----带4K可编程FLASH闪存的8位微控制器书签:---特性---描述---引脚配制---引脚描述---特殊功能寄存器---内存组织---看门狗定时器---使用看门狗定时器---掉电模式和节电模式下的看门狗定时器---定时器0和1---中断---振荡器特性---节电模式---掉电模式---程序存储器控制位--- 闪存编程平行模式---闪存编程连续模式--- 接口编程平行模式---闪存编程和确认平行模式---闪存编程和确认波形连续模式---最大绝对额定值---直流电特性---交流电特性---外部程序和数据存储器特性---外部程序存储器读周期---外部数据存储器读周期---外部数据存储器写周期---外部时钟驱动波形---外部时钟驱动---串行端口定时:移位寄存器模式测试条件---移位寄存器模式定时脉冲波形---交流电测试I/O波形---浮动波形---订购信息---封装信息特性与MCS-51产品兼容4K字节可编程快闪存储器耐久度:1000写入/擦除周期4.0V-5.5V的工作电压范围完全静态工作频率范围: 0 Hz to 33 MHz三级程序存储器锁128字节内部RAM32条可编程I/O线2个16位定时器/计数器6个中断源全双工通信异步收发连续信道低电压节电和掉电模式掉电模式的中断恢复看门狗定时器双数据指针断电标志快的编程时间灵活的在线下载编程字节和页模式描述AT89S51是一款低功耗,高性能,CMOS工艺的8位微控制器,并带有4K字节的可编程FLASH 存储器。
AT89S51单片机简介

一、AT89S51单片机简介AT89S51 为 ATMEL 所生产的可电气烧录清洗的 8051 相容单芯片,其内部程序代码容量为4KB(一)、AT89S51主要功能列举如下:1、为一般控制应用的 8 位单芯片2、晶片内部具时钟振荡器(传统最高工作频率可至 12MHz )3、内部程式存储器(ROM )为 4KB4、内部数据存储器(RAM )为 128B5、外部程序存储器可扩充至 64KB6、外部数据存储器可扩充至 64KB7、32 条双向输入输出线,且每条均可以单独做 I/O 的控制8、5 个中断向量源9、2 组独立的 16 位定时器10、1 个全多工串行通信端口11、8751 及 8752 单芯片具有数据保密的功能12、单芯片提供位逻辑运算指令(二)、AT89S51各引脚功能介绍:VCC :AT89S51 电源正端输入,接+5V 。
VSS :电源地端。
XTAL1:单芯片系统时钟的反相放大器输入端。
XTAL2:系统时钟的反相放大器输出端,一般在设计上只要在 XTAL1 和 XTAL2 上接上一只石英振荡晶体系统就可以动作了,此外可以在两引脚与地之间加入一20PF 的小电容,可以使系统更稳定,避免噪声干扰而死机。
RESET :AT89S51的重置引脚,高电平动作,当要对晶片重置时,只要对此引脚电平提升至高电平并保持两个机器周期以上的时间,AT89S51便能完成系统重置的各项动作,使得内部特殊功能寄存器之内容均被设成已知状态,并且至地址0000H处开始读入程序代码而执行程序。
EA/Vpp:"EA"为英文"External Access"的缩写,表示存取外部程序代码之意,低电平动作,也就是说当此引脚接低电平后,系统会取用外部的程序代码(存于外部EPROM中)来执行程序。
因此在8031及8032中,EA引脚必须接低电平,因为其内部无程序存储器空间。
如果是使用8751 内部程序空间时,此引脚要接成高电平。
单片机第3章 AT89S51单片机的指令系统

单片机第3章 AT89S51单片机的指令系统在单片机的世界里,指令系统就像是指挥单片机工作的“语言”,它决定了单片机能够完成哪些任务以及如何高效地完成这些任务。
AT89S51 单片机的指令系统丰富多样,为我们实现各种功能提供了强大的支持。
首先,让我们来了解一下指令的基本格式。
AT89S51 单片机的指令通常由操作码和操作数两部分组成。
操作码指明了要执行的操作,比如加法、减法、数据传送等;操作数则提供了操作所需的具体数据或者数据的地址。
AT89S51 单片机的指令可以分为数据传送类指令、算术运算类指令、逻辑运算类指令、控制转移类指令等几大类。
数据传送类指令是最为基础和常用的指令之一。
比如 MOV 指令,它可以实现将一个数据从一个位置传送到另一个位置。
例如 MOV A,50H ,就是将十六进制数 50H 传送到累加器 A 中。
算术运算类指令用于进行加、减、乘、除等运算。
例如 ADD A, R0 ,就是将累加器 A 的内容和寄存器 R0 的内容相加,结果存放在累加器A 中。
逻辑运算类指令则用于对数据进行与、或、异或等逻辑操作。
比如ANL A, 0FH ,就是将累加器 A 的内容和十六进制数 0FH 进行与运算。
控制转移类指令在程序的流程控制中起着关键作用。
比如JZ label ,如果累加器 A 的内容为 0 ,则程序跳转到指定的 label 处执行。
在实际编程中,我们需要根据具体的需求灵活运用这些指令。
比如,当我们要实现一个简单的加法运算时,可以使用算术运算类指令;当需要在不同的程序段之间跳转时,就需要用到控制转移类指令。
为了更好地理解和运用 AT89S51 单片机的指令系统,我们还需要了解一些指令的执行周期和寻址方式。
指令的执行周期决定了指令执行的速度。
不同的指令执行周期可能不同,这会影响程序的运行效率。
而寻址方式则决定了如何获取操作数。
AT89S51 单片机支持直接寻址、寄存器寻址、寄存器间接寻址、立即寻址等多种寻址方式。
at89s51 中文数据手册

AT89S51中文资料AT89S51是美国ATMEL公司生产的低功耗,高性能CMOS8位单片机,片内含4k bytes的可系统编程的Flash只读程序存储器,器件采用ATMEL公司的高密度、非易失性存储技术生产,兼容标准8051指令系统及引脚。
它集Flash 程序存储器既可在线编程(ISP)也可用传统方法进行编程及通用8位微处理器于单片芯片中,ATMEL公司的功能强大,低价位AT89S51单片机可为您提供许多高性价比的应用场合,可灵活应用于各种控制领域。
主要性能参数:·与MCS-51产品指令系统完全兼容·4k字节在系统编程(ISP)Flash闪速存储器·1000次擦写周期·4.0-5.5V的工作电压范围·全静态工作模式:0Hz-33MHz·三级程序加密锁·128×8字节内部RAM·32个可编程I/O口线·2个16位定时/计数器·6个中断源·全双工串行UART通道·低功耗空闲和掉电模式·中断可从空闲模唤醒系统·看门狗(WDT)及双数据指针·掉电标识和快速编程特性·灵活的在系统编程(ISP字节或页写模式)功能特性概述:AT89S51 提供以下标准功能:4k 字节Flash 闪速存储器,128字节内部RAM,32个I/O 口线,看门狗(WDT),两个数据指针,两个16 位定时/计数器,一个5 向量两级中断结构,一个全双工串行通信口,片内振荡器及时钟电路。
同时,AT89S51可降至0Hz的静态逻辑操作,并支持两种软件可选的节电工作模式。
空闲方式停止CPU 的工作,但允许RAM,定时/计数器,串行通信口及中断系统继续工作。
掉电方式保存RAM 中的内容,但振荡器停止工作并禁止其它所有部件工作直到下一个硬件复位。
AT89S51方框图引脚功能说明·Vcc:电源电压·GND:地·P0口:P0口是一组8位漏极开路型双向I/0口,也即地址/数据总线复用口。
AT89S51单片机简介

一、AT89S51单片机简介AT89S51 为 ATMEL 所生产的可电气烧录清洗的 8051 相容单芯片,其内部程序代码容量为4KB(一)、AT89S51主要功能列举如下:1、为一般控制应用的 8 位单芯片2、晶片内部具时钟振荡器(传统最高工作频率可至 12MHz )3、内部程式存储器(ROM )为 4KB4、内部数据存储器(RAM )为 128B5、外部程序存储器可扩充至 64KB6、外部数据存储器可扩充至 64KB7、32 条双向输入输出线,且每条均可以单独做 I/O 的控制8、5 个中断向量源9、2 组独立的 16 位定时器10、1 个全多工串行通信端口11、8751 及 8752 单芯片具有数据保密的功能12、单芯片提供位逻辑运算指令(二)、AT89S51各引脚功能介绍:VCC :AT89S51 电源正端输入,接+5V 。
VSS :电源地端。
XTAL1:单芯片系统时钟的反相放大器输入端。
XTAL2:系统时钟的反相放大器输出端,一般在设计上只要在 XTAL1 和 XTAL2上接上一只石英振荡晶体系统就可以动作了,此外可以在两引脚与地之间加入一 20PF 的小电容,可以使系统更稳定,避免噪声干扰而死机。
RESET :AT89S51的重置引脚,高电平动作,当要对晶片重置时,只要对此引脚电平提升至高电平并保持两个机器周期以上的时间,AT89S51便能完成系统重置的各项动作,使得内部特殊功能寄存器之内容均被设成已知状态,并且至地址0000H处开始读入程序代码而执行程序。
EA/Vpp:"EA"为英文"External Access"的缩写,表示存取外部程序代码之意,低电平动作,也就是说当此引脚接低电平后,系统会取用外部的程序代码(存于外部EPROM中)来执行程序。
因此在8031及8032中,EA引脚必须接低电平,因为其内部无程序存储器空间。
如果是使用8751 内部程序空间时,此引脚要接成高电平。
单片机第8章 AT89S51单片机串行通信技术

单片机原理、应用与仿真
8.1.2电源控制寄存器PCON
AT89S51单片机的串口由2个数据缓冲器、1个移位寄存器和1 个串行控制寄存器等组成。数据缓冲器由串行接收缓冲器和发 送缓冲器构成,它们在物理上是独立的,既可以接收数据也可 以发送数据,还可以同时发送和接收数据。接收缓冲器只能读 出,不能写入,而发送缓冲器则只能写入,不能读出。它们共 用一个地址(99H)。
sm0sm1工作方式功能简述工作方式0移位寄存器工作方式波特率为12工作方式18位数据异步收发波特率可变工作方式29位数据异步收发波特率为32或64工作方式39位数据异步收发波特率可变表81串行通信工作方式单片机原理应用与仿真811串行口控制寄存器sconsm2
第8章 AT89S51单片机串行通信接 口技术
(1)电气特性
RS-485的信号传输采用两线间的电压来表示逻辑1和逻 辑0,数据采用差分传输,抗干扰能力强,传输距离可达 到1200m,传输速率可达10Mb/s。
驱动器输出电平在-1.5V以下时为逻辑1,在+1.5V以上时 为逻辑0。接收器输入电平在-0.2V以下时为逻辑1,在 +0.2V以上为逻辑0。
FDH
--
14400
FCH
FEH
9600
FAH
FDH
4800
F4H
FAH
2400
单片机原理、应用与仿真
1200
E8H D0H
单片机简介 AT89C51中文资料

4.1 单片机介绍:单片机是指一个集成在一块芯片上的完整计算机系统。
尽管他的大部分功能集成在一块小芯片上,但是它具有一个完整计算机所需要的大部分部件:CPU、内存、内部和外部总线系统,目前大部分还会具有外存。
同时集成诸如通讯接口、定时器,实时时钟等外围设备。
而现在最强大的单片机系统甚至可以将声音、图像、网络、复杂的输入输出系统集成在一块芯片上。
单片机也被称为微控制器(Microcontroler),是因为它最早被用在工业控制领域。
单片机由芯片内仅有CPU的专用处理器发展而来。
最早的设计理念是通过将大量外围设备和CPU集成在一个芯片中,使计算机系统更小,更容易集成进复杂的而对提及要求严格的控制设备当中。
INTEL的Z80是最早按照这种思想设计出的处理器,从此以后,单片机和专用处理器的发展便分道扬镳。
早期的单片机都是8位或4位的。
其中最成功的是INTEL的8031,因为简单可靠而性能不错获得了很大的好评。
此后在8031上发展出了MCS51系列单片机系统。
基于这一系统的单片机系统直到现在还在广泛使用。
随着工业控制领域要求的提高,开始出现了16位单片机,但因为性价比不理想并未得到很广泛的应用。
90年代后随着消费电子产品大发展,单片机技术得到了巨大的提高。
随着INTEL i960系列特别是后来的ARM系列的广泛应用,32位单片机迅速取代16位单片机的高端地位,并且进入主流市场。
而传统的8位单片机的性能也得到了飞速提高,处理能力比起80年代提高了数百倍。
目前,高端的32位单片机主频已经超过300MHz,性能直追90年代中期的专用处理器,而普通的型号出厂价格跌落至1美元,最高端的型号也只有10美元。
当代单片机系统已经不再只在裸机环境下开发和使用,大量专用的嵌入式操作系统被广泛应用在全系列的单片机上。
而在作为掌上电脑和手机核心处理的高端单片机甚至可以直接使用专用的Windows和Linux操作系统。
单片机比专用处理器更适合应用于嵌入式系统,因此它得到了最多的应用。
ATM89C51单片机简介(中英双语)

ATM89C51单⽚机简介(中英双语)原⽂:The Introduction of AT89C51DescriptionThe AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmel’s high-density nonvolatile memory technology and is compatible with the industry-standard MCS-51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.Function characteristicThe AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bittimer/counters, a five vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt system to continue functioning. The Power-down Mode saves the RAM contents but freezes the oscillator disabling all other chip functions until the next hardware reset.Pin DescriptionVCC:Supply voltage.GND:Ground.Port 0Port 0 is an 8-bit open-drain 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 highimpedance inputs.Port 0 may also be configured to be the multiplexed loworder address/data bus during accesses to external program and data memory. In this mode P0 has internal pullups.Port 0 also receives the code bytes during Flash programming,and outputs the code bytes during programverification. External pullups are required during programverification.Port 1Port 1 is an 8-bit bi-directional I/O port with internal pullups.The Port 1 output buffers can sink/source four TTL inputs.When 1s are written to Port 1 pins they are pulled high by the internal pullups 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 pullups.Port 1 also receives the low-order address bytes during Flash programming and verification.Port 2Port 2 is an 8-bit bi-directional I/O port with internal pullups.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 pullups and can be used as inputs. As inputs,Port 2 pins that are externally being pulled low will source current, because of the internal pullups.Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses. In this application, it uses strong internal pullupswhen emitting 1s. During accesses to external data memory that use 8-bit addresses, 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 pullups.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 pullups and can be used as inputs. As inputs,Port 3 pins that are externally being pulled low will source current (IIL) because of the pullups.Port 3 also serves the functions of various special features of the AT89C51 as listed below: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/PROGAddress Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) 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 clocking 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 bitset, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.PSENProgram Store Enable is the read strobe to external program memory.When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.EA/VPPExternal Access Enable. EA 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, EA will be internally latched on reset.EA should be strapped to VCC for internal program executions.This pin also receives the 12-volt programming enable voltage(VPP) during Flash programming, for parts that require12-volt VPP.XTAL1Input to the inverting oscillator amplifier and input to the internal clock operating circuit.XTAL2Output from the inverting oscillator amplifier.Oscillator CharacteristicsXTAL1 and XTAL2 are the input and output, respectively,of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figure 1.Either aquartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 2.There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.Figure 1. Oscillator Connections Figure 2. External Clock Drive ConfigurationIdle ModeIn idle mode, the CPU puts itself to sleep while all the onchip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset.It should be noted that when idle is terminated by a hard ware reset, the device normally resumes program execution,from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory.Power-down ModeIn the power-down mode, the oscillator is stopped, and the instruction that invokes power-down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power-down mode is terminated. The only exit from power-down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its normal operating level and must be held active long enough to allow the oscillator to restart and stabilize.Program Memory Lock BitsOn the chip are three lock bits which can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in the table below.When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched during reset. If the device is powered up without a reset, the latch initializes to a random value, and holds that value until reset is activated. It is necessary that the latched value of EA be in agreement with the current logic level at that pin in order for the device to function properly.译⽂:AT89C51的介绍描述AT89C51是⼀个低电压,⾼性能CMOS 8位单⽚机带有4K字节的可反复擦写的程序存储器(PENROM)。
AT89S51单片机简介

一、AT89S51单片机简介AT89S51为ATMEL所生产的可电气烧录清洗的8051相容单芯片,其内部程序代码容量为4KB(一)、AT89S51主要功能列举如下:1、为一般控制应用的8位单芯片2、晶片内部具时钟振荡器(传统最高工作频率可至12MHz)3、内部程式存储器(ROM)为4KB4、内部数据存储器(RAM)为128B5、外部程序存储器可扩充至64KB6、外部数据存储器可扩充至64KB7、32条双向输入输出线,且每条均可以单独做I/O的控制8、5个中断向量源9、2组独立的16位定时器10、1个全多工串行通信端口11、8751及8752单芯片具有数据保密的功能12、单芯片提供位逻辑运算指令(二)、AT89S51各引脚功能介绍:VCC:AT89S51电源正端输入,接+5V。
VSS:电源地端。
XTAL1:单芯片系统时钟的反相放大器输入端。
XTAL2:系统时钟的反相放大器输出端,一般在设计上只要在XTAL1和XTAL2上接上一只石英振荡晶体系统就可以动作了,此外可以在两引脚与地之间加入一20PF的小电容,可以使系统更稳定,避免噪声干扰而死机。
RESET:AT89S51的重置引脚,高电平动作,当要对晶片重置时,只要对此引脚电平提升至高电平并保持两个机器周期以上的时间,AT89S51便能完成系统重置的各项动作,使得内部特殊功能寄存器之AT89S51内容均被设成已知状态,并且至地址0000H处开始读入程序代码而执行程序。
EA/Vpp:"EA"为英文"ExternalAccess"的缩写,表示存取外部程序代码之意,低电平动作,也就是说当此引脚接低电平后,系统会取用外部的程序代码(存于外部EPROM中)来执行程序。
因此在8031及8032中,EA引脚必须接低电平,因为其内部无程序存储器空间。
如果是使用8751内部程序空间时,此引脚要接成高电平。
此外,在将程序代码烧录至8751内部EPROM时,可以利用此引脚来输入21V的烧录高压(Vpp)。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
1AT89S51是美国ATMEL 公司生产的低功耗,高性能CMOS8位单片机,片内含4k bytes 的可系统编程的Flash 只读程序存储器,器件采用ATMEL 公司的高密度、非易失性存储技术生产,兼容标准8051指令系统及引脚。
它集Flash 程序存储器既可在线编程(ISP )也可用传统方法进行编程及通用8位微处理器于单片芯片中,ATMEL 公司的功能强大,低价位AT89S51单片机可为您提供许多高性价比的应用场合,可灵活应用于各种控制领域。
主要性能参数:·与MCS-51产品指令系统完全兼容·4k 字节在系统编程(ISP )Flash 闪速存储器 ·1000次擦写周期·4.0-5.5V 的工作电压范围 ·全静态工作模式:0Hz -33MHz ·三级程序加密锁 ·128×8字节内部RAM ·32个可编程I /O 口线 ·2个16位定时/计数器 ·6个中断源·全双工串行UART 通道 ·低功耗空闲和掉电模式 ·中断可从空闲模唤醒系统 ·看门狗(WDT )及双数据指针 ·掉电标识和快速编程特性·灵活的在系统编程(ISP 字节或页写模式)2功能特性概述:A T89S51提供以下标准功能:4k 字节Flash 闪速存储器,128字节内部RAM ,32个I /O 口线,看门狗(WDT ),两个数据指针,两个16位定时/计数器,一个5向量两级中断结构,一个全双工串行通信口,片内振荡器及时钟电路。
同时,A T89S51可降至0Hz 的静态逻辑操作,并支持两种软件可选的节电工作模式。
空闲方式停止CPU 的工作,但允许RAM ,定时/计数器,串行通信口及中断系统继续工作。
掉电方式保存RAM 中的内容,但振荡器停止工作并禁止其它所有部件工作直到下一个硬件复位。
AT89S51方框图4端口引脚 第二功能P3.0 RXD (串行输入口) P3.1 TXD (串行输出口) P3.2 INT0————(外中断0) P3.3 INT1————(外中断1)P3.4 T0(定时/计数器0外部输入) P3.5 T1(定时/计数器1外部输入) P3.6 WR ———(外部数据存储器写选通)P3.7RD ———(外部数据存储器读选通)·RST :复位输入。
当振荡器工作时,RST 引脚出现两个机器周期以上高电平将使单片机复位。
WDT 溢出将使该引脚输出高电平,设置SFR AUXR 的DISRT0位(地址8EH )可打开或关闭该功能。
DISRT0位缺省为RESET 输出高电平打开状态。
·ALE /PROG —————:当访问外部程序存储器或数据存储器时,ALE (地址锁存允许)输出脉冲用于锁存地址的低8位字节。
即使不访问外部存储器,ALE 仍以时钟振荡频率的1/6输出固定的正脉冲信号,因此它可对外输出时钟或用于定时目的。
要注意的是:每当访问外部数据存储器时将跳过一个ALE 脉冲。
对F1ash 存储器编程期间,该引脚还用于输入编程脉冲(PROG )。
如有必要,可通过对特殊功能寄存器(SFR )区中的8EH 单元的D0位置位,可禁止ALE 操作。
该位置位后,只有一条M0VX 和M0VC 指令ALE 才会被激活。
此外,该引脚会被微弱拉高,单片机执行外部程序时,应设置ALE 无效。
·PSEN —————:程序储存允许(PSEN —————)输出是外部程序存储器的读选通信号,当A T89S51由外部程序存储器取指令(或数据)时,每个机器周期两次PSEN —————有效,即输出两个脉冲。
当访问外部数据存储器,没有两次有效的PSEN —————信号。
·EA /VPP :外部访问允许。
欲使CPU 仅访问外部程序存储器(地址为0000H -FFFFH ),EA 端必须保持低电平(接地)。
需注意的是:如果加密位LB1被编程,复位时内部会锁存EA 端状态。
如EA 端为高电平(接Vcc 端),CPU 则执行内部程序存储器中的指令。
F1ash 存储器编程时,该引脚加上+12V 的编程电压Vpp 。
·XTALl :振荡器反相放大器及内部时钟发生器的输入端。
·XTAL2:振荡器反相放大器的输出端。
·特殊功能寄存器:特殊功能寄存器的于片内的空间分布如表1所示。
这些地址并没有全部占用,没有占用的地址亦不可使用,读这些地址将得到一个随意的数值。
而写这些地址单元将不能得到预期的结果。
表1 A T89S51特殊功能寄存器分布图及复位值不要软件访问这些未定义的单元,这些单元是留作以后产品扩展用途的,复位后这些新的位将为0。
·中断寄存器:各中断允许控制位于IE寄存器,5个中断源的中断优先级控制位于IP寄存器。
5表2 AUXR辅助寄存器·双时钟指针寄存器:为更方便地访问内部和外部数据存储器,提供了两个16位数据指针寄存器:DP0位于SFR(特殊功能寄存器)区块中的地址82H、83H和DP1位于地址84H、85H,当SFR中的位DPS=0选择DP0,而DPS=1则选择DP1。
用户应在访问相应的数据指针寄存器前初始化DPS位。
6·电源空闲标志:电源空闲标志(POF)在特殊功能寄存器SFR中PCON的第4位(PCON.4),电源打开时POF置“1",它可由软件设置睡眠状态并不为复位所影响。
·存储器结构:MCS-51单片机内核采用程序存储器和数据存储器空间分开的结构,均具有64KB外部程序和数据的寻址空间。
·程序存储器:如果EA引脚接地(GND),全部程序均执行外部存储器。
在A T89S51,假如EA接至Vcc(电源+),程序首先执行地址从0000H-0FFFH(4KB)内部程序存储器,再执行地址为1000H-FFFFH(60KB)的外部程序存储器。
·数据存储器:A T89S51的具有128字节的内部RAM,这128字节可利用直接或间接寻址方式访问,堆栈操作可利用间接寻址方式进行,128字节均可设置为堆栈区空间。
·看门狗定时器(WDT):WDT是为了解决CPU程序运行时可能进入混乱或死循环而设置,它由一个14bit计数器和看门狗复位SFR(WDTRST)构成。
外部复位时,WDT默认为关闭状态,要打开WDT,用户必须按顺序将01EH和0E1H写到WDTRST寄存器(SFR 地址为0A6H),当启动了WDT,它会随晶体振荡器在每个机器周期计数,除硬件复位或WDT溢出复位外没有其它方法关闭WDT,当WDT溢出,将使RST引脚输出高电平的复位脉冲。
·使用看门狗(WDT):打开WDT需按次序写01EH和0E1H到WDTRST寄存器(SFR的地址为0A6H),当WDT打开后,需在一定的时候01EH和0E1H到WDTRST寄存器以避免WDT计数溢出。
14位WDT计数器计数达到16383(3FFFH),WDT将溢出并使器件复位。
WDT打开时,它会随晶体振荡器在每个机器周期计数,这意味着用户必须在小于每个16383机器周期内复位WDT,也即写01EH和0E1H到WDTRST寄存器,WDTRST为只写寄存器。
WDT计数器既不可读也不可写,当WDT 溢出时,通常将使RST引脚输出高电平的复位脉冲。
复位脉冲持续时间为98×Tosc,而Tosc=1/Fosc(晶体振荡频率)。
为使WDT工作最优化,必须在合适的程序代码时间段周期地复位WDT防止WDT溢出。
·掉电和空闲状态时的WDT:掉电时期,晶体振荡停止,WDT也停止。
掉电模式下,用户不能再复位WDT。
有两种方法可退出掉电模式:硬件复位或通过激活外部中断。
当硬件复位退出掉电模式时,处理WDT可象通常的上电复位一样。
当由中断退出掉电模式则有所不同,中断低电平状态持续到晶体振荡稳定,当中断电平变为高即响应中断服务。
为防止中断误复位,当器件复位,中断引脚持续为低时,WDT并未开始计数,直到中断引脚被拉高为止。
这为在掉电模式下的中断执行中断服务程序而设置。
为保证WDT在退出掉电模式时极端情况下不溢出,最好在进入掉电模式前复位WDT。
在进入空闲模式前,WDT打开时,WDT是否继续计数由SFR中的AUXR的WDIDLE位决定,在IDLE期间(位WDIDLE=0)默认状态是继续计数。
为防止A T89S51从空闲模式中复位,用户应周期性地设置定时器,重新进入空闲模式。
当位WDIDLE被置位,在空闲模式中WDT将停止计数,直到从空闲(IDLE)模式中退出重新开始计数。
7·UART-通用异步通信口:A T89S51的UART操作与A T89C51一样,有关更详细的资料请参考A TMEL公司的网站(),从主页选择“Products”-“8051-Architecture Flash Microcontroller”-“Product Overview"。
·定时器0和定时器1:A T89S51的定时器0和定时器1操作与A T89C51一样,有关更详细的资料请参考A TMEL公司的网站(),从主页选择“Products”-“8051-Architecture Flash Microcontroller”-“Product Overview”。
·中断:A T89S51共有5个中断向量:2个外中断(INT0和INT1),2个定时中断(Timer0和Timer1)和一个串行中断。
这些中断如图1:这些中断源各自的禁止和使能位参见特殊功能寄存器的IE。
IE也包含总中断控制位EA,EA清0,将关闭所有中断。
值得注意的是表4中的IE.6和IE.5没有定义,用户不要访问这些位,它是保留为以后的A T89产品作扩展用途。
定时器0和定时器1的中断标志TF0和TF1,它是定时器溢出时的S5P2时序周期被置位,该标志保留至下个时序周期。
表4:中断控制寄存器89图1 中断源方框图·晶体振荡器特性:A T89S51中有一个用于构成内部振荡器的高增益反相放大器,引脚XTAL1和XTAL2分别是该放大器的输入端和输出端。
这个放大器与作为反馈元件的片外石英晶体或陶瓷谐振器一起构成自激振荡器,振荡电路参见图5。
外接石英晶体(或陶瓷谐振器)及电容Cl 、C2接在放大器的反馈回路中构成并联振荡电路。
对外接电容Cl 、C2虽然没有十分严格的要求,但电容容量的大小会轻微影响振荡频率的高低、振荡器工作的稳定性、起振的难易程序及温度稳定性。
如果使用石英晶体,我们推荐电容使用30pF ±10pF ,而如使用陶瓷谐振器建议选择40pF ±10F 。