图片仅供参考

详细数据请看参考数据手册

Datasheet下载
  • 型号: AT89S2051-24PU
  • 制造商: Atmel
  • 库位|库存: xxxx|xxxx
  • 要求:
数量阶梯 香港交货 国内含税
+xxxx $xxxx ¥xxxx

查看当月历史价格

查看今年历史价格

AT89S2051-24PU产品简介:

ICGOO电子元器件商城为您提供AT89S2051-24PU由Atmel设计生产,在icgoo商城现货销售,并且可以通过原厂、代理商等渠道进行代购。 AT89S2051-24PU价格参考¥11.50-¥12.38。AtmelAT89S2051-24PU封装/规格:嵌入式 - 微控制器, 8051 微控制器 IC 89S 8-位 24MHz 2KB(2K x 8) 闪存 20-PDIP。您可以下载AT89S2051-24PU参考资料、Datasheet数据手册功能说明书,资料中有AT89S2051-24PU 详细功能的应用电路图电压和使用方法及教程。

产品参数 图文手册 常见问题
参数 数值
A/D位大小

No ADC

产品目录

集成电路 (IC)半导体

描述

IC MCU 8BIT 2KB FLASH 20DIP8位微控制器 -MCU 2K FLSH 24MHZ

EEPROM容量

-

产品分类

嵌入式 - 微控制器

I/O数

15

品牌

Atmel

产品手册

点击此处下载产品Datasheet

产品图片

rohs

符合RoHS无铅 / 符合限制有害物质指令(RoHS)规范要求

产品系列

嵌入式处理器和控制器,微控制器 - MCU,8位微控制器 -MCU,Atmel AT89S2051-24PU89S

数据手册

点击此处下载产品Datasheet

产品型号

AT89S2051-24PU

RAM容量

256 x 8

产品培训模块

http://www.digikey.cn/PTM/IndividualPTM.page?site=cn&lang=zhs&ptm=24997http://www.digikey.cn/PTM/IndividualPTM.page?site=cn&lang=zhs&ptm=26162http://www.digikey.cn/PTM/IndividualPTM.page?site=cn&lang=zhs&ptm=26159http://www.digikey.cn/PTM/IndividualPTM.page?site=cn&lang=zhs&ptm=26180

产品种类

8位微控制器 -MCU

供应商器件封装

20-PDIP

其它名称

AT89S205124PU

包装

管件

可编程输入/输出端数量

15

商标

Atmel

处理器系列

AT89x

外设

欠压检测/复位,POR,PWM

安装风格

Through Hole

定时器数量

2 Timer

封装/外壳

20-DIP(0.300",7.62mm)

封装/箱体

PDIP

工作温度

-40°C ~ 85°C

工作电源电压

2.7 V to 5.5 V

工厂包装数量

18

振荡器类型

内部

接口类型

UART

数据RAM大小

256 B

数据总线宽度

8 bit

数据转换器

-

最大工作温度

+ 85 C

最大时钟频率

24 MHz

最小工作温度

- 40 C

标准包装

18

核心

8051

核心处理器

8051

核心尺寸

8-位

片上ADC

No

电压-电源(Vcc/Vdd)

2.7 V ~ 5.5 V

电源电压-最大

5.5 V

电源电压-最小

2.7 V

程序存储器大小

2 kB

程序存储器类型

Flash

程序存储容量

2KB(2K x 8)

系列

89S

输入/输出端数量

15 I/O

连接性

UART/USART

速度

24MHz

推荐商品

型号:PIC32MX210F016D-I/PT

品牌:Microchip Technology

产品名称:集成电路(IC)

获取报价

型号:EFM32TG110F16-QFN24T

品牌:Silicon Labs

产品名称:集成电路(IC)

获取报价

型号:AT89C51CC03UA-SLSUM

品牌:Microchip Technology

产品名称:集成电路(IC)

获取报价

型号:PIC16F785-E/ML

品牌:Microchip Technology

产品名称:集成电路(IC)

获取报价

型号:MC68HC11E1CFNE2

品牌:NXP USA Inc.

产品名称:集成电路(IC)

获取报价

型号:PIC12F629-I/MD

品牌:Microchip Technology

产品名称:集成电路(IC)

获取报价

型号:PIC16F73-I/ML

品牌:Microchip Technology

产品名称:集成电路(IC)

获取报价

型号:M30622SPGP#U3C

品牌:Renesas Electronics America

产品名称:集成电路(IC)

获取报价

样品试用

万种样品免费试用

去申请
AT89S2051-24PU 相关产品

MCL908QY2CDWE

品牌:NXP USA Inc.

价格:

M30622F8PGP#U3C

品牌:Renesas Electronics America

价格:

MC68331CFC16

品牌:NXP USA Inc.

价格:¥185.87-¥211.21

P89LPC914FDH,129

品牌:NXP USA Inc.

价格:

STM32L151C8U6

品牌:STMicroelectronics

价格:

PIC16F1824-I/JQ

品牌:Microchip Technology

价格:

NUC123LD4AN0

品牌:Nuvoton Technology Corporation of America

价格:

DSPIC33EP64MC204-E/TL

品牌:Microchip Technology

价格:

PDF Datasheet 数据手册内容提取

Features • Compatible with MCS®51 Products (cid:129) 2K/4K Bytes of In-System Programmable (ISP) Flash Program Memory – Serial Interface for Program Downloading – Endurance: 10,000 Write/Erase Cycles (cid:129) 2.7V to 5.5V Operating Range (cid:129) Fully Static Operation: 0 Hz to 24 MHz (x1 and x2 Modes) (cid:129) Two-level Program Memory Lock (cid:129) 256 x 8-bit Internal RAM 8-bit (cid:129) 15 Programmable I/O Lines (cid:129) Two 16-bit Timer/Counters Microcontroller (cid:129) Six Interrupt Sources (cid:129) Programmable Serial UART Channel with 2K/4K (cid:129) Direct LED Drive Outputs (cid:129) On-chip Analog Comparator with Selectable Interrupt Bytes Flash (cid:129) 8-bit PWM (Pulse-width Modulation) (cid:129) Low Power Idle and Power-down Modes (cid:129) Brownout Reset (cid:129) Enhanced UART Serial Port with Framing Error Detection and Automatic AT89S2051 Address Recognition (cid:129) Internal Power-on Reset AT89S4051 (cid:129) Interrupt Recovery from Power-down Mode (cid:129) Programmable and Fuseable x2 Clock Option (cid:129) Four-level Enhanced Interrupt Controller (cid:129) Power-off Flag (cid:129) Flexible Programming (Byte and Page Modes) – Page Mode: 32 Bytes/Page (cid:129) User Serviceable Signature Page (32 Bytes) 1. Description The AT89S2051/S4051 is a low-voltage, high-performance CMOS 8-bit microcon- troller with 2K/4K bytes of In-System Programmable (ISP) Flash program memory. The device is manufactured using Atmel’s high-density nonvolatile memory technol- ogy and is compatible with the industry-standard MCS-51 instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S2051/S4051 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. Moreover, the AT89S2051/S4051 is designed to be function compatible with the AT89C2051/C4051 devices, respectively. The AT89S2051/S4051 provides the following standard features: 2K/4K bytes of Flash, 256 bytes of RAM, 15 I/O lines, two 16-bit timer/counters, a six-vector, four- level interrupt architecture, a full duplex enhanced serial port, a precision analog comparator, on-chip and clock circuitry. Hardware support for PWM with 8-bit resolu- tion and 8-bit prescaler is available by reconfiguring the two on-chip timer/counters. In addition, the AT89S2051/S4051 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 disabling all other chip functions until the next external interrupt or 3390E–MICRO–6/08 hardware reset.

The on-board Flash program memory is accessible through the ISP serial interface. Holding RST active forces the device into a serial programming interface and allows the program mem- ory to be written to or read from, unless one or more lock bits have been activated. 2. Pin Configuration 2.1 20-lead PDIP/SOIC RST/VPP 1 20 VCC (RXD) P3.0 2 19 P1.7 (SCK) (TXD) P3.1 3 18 P1.6 (MISO) XTAL2 4 17 P1.5 (MOSI) XTAL1 5 16 P1.4 (INT0) P3.2 6 15 P1.3 (INT1) P3.3 7 14 P1.2 (T0) P3.4 8 13 P1.1 (AIN1) (T1) P3.5 9 12 P1.0 (AIN0) GND 10 11 P3.7 3. Block Diagram AT89S2051/S4051 2 3390E–MICRO–6/08

AT89S2051/S4051 4. Pin Description 4.1 VCC Supply voltage. 4.2 GND Ground. 4.3 Port 1 Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 to P1.7 provide internal pull-ups. P1.0 and P1.1 require external pull-ups. P1.0 and P1.1 also serve as the positive input (AIN0) and the negative input (AIN1), respectively, of the on-chip precision analog comparator. The Port 1 out- put buffers can sink 20 mA and can drive LED displays directly. When 1s are written to Port 1 pins, they can be used as inputs. When pins P1.2 to P1.7 are used as inputs and are externally pulled low, they will source current (I ) because of the internal pull-ups. IL Port 1 also receives code data during Flash programming and verification. Port Pin Alternate Functions P1.5 MOSI (Master data output, slave data input pin for ISP channel) P1.6 MISO (Master data input, slave data output pin for ISP channel) P1.7 SCK (Master clock output, slave clock input pin for ISP channel) 4.4 Port 3 Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal pull-ups. P3.6 is hard-wired as an input to the output of the on-chip comparator and is not accessible as a general-purpose I/O pin. The Port 3 output buffers can sink 20 mA. 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 (I ) because of the pull-ups. IL Port 3 also serves the functions of various special features of the AT89S2051/S4051 as listed below: Port Pin Alternate Functions P3.0 RXD (serial input port) P3.1 TXD (serial output port) P3.2 INT0 (external interrupt 0) P3.3 INT1 (external interrupt 1) P3.4 T0 (timer 0 external input) P3.5 T1 (timer 1 external input)/ PWM output Port 3 also receives some control signals for Flash programming and verification. 3 3390E–MICRO–6/08

4.5 RST Reset input. Holding the RST pin high for two machine cycles while the is running resets the device. Each machine cycle takes 6 or clock cycles. 4.6 XTAL1 Input to the inverting amplifier and input to the internal clock operating circuit. 4.7 XTAL2 Output from the inverting amplifier. 5. Characteristics XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip , as shown in Figure 5-1. Either a quartz crystal or ceramic res- onator 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 5-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 5-1. Connections Note: C1, C2 = 5 pF ± 5 pF for Crystals = 5 pF ± 5 pF for Ceramic Resonators Figure 5-2. External Clock Drive Configuration AT89S2051/S4051 4 3390E–MICRO–6/08

AT89S2051/S4051 6. X2 Mode Description The clock for the entire circuit and peripherals is normally divided by 2 before being used by the CPU core and peripherals. This allows any cyclic ratio (duty cycle) to be accepted on XTAL1 input. In X2 mode this divider is bypassed. Figure 6-1 shows the clock generation block diagram. Figure 6-1. Clock Generation Block Diagram X2 Mode XTAL1 ÷2 (XTAL1)/2 F XTAL State Machine: 6 Clock Cycles F CPU Control OSC 7. Special Function Registers A map of the on-chip memory area called the Special Function Register (SFR) space is shown in Table 7-1. Note that not all of the addresses are occupied, and unoccupied addresses may not be imple- mented 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. 5 3390E–MICRO–6/08

Table 7-1. AT89S2051/S4051 SFR Map and Reset Values 0F8H 0FFH B 0F0H 0F7H 00000000 0E8H 0EFH ACC 0E0H 0E7H 00000000 0D8H 0DFH PSW 0D0H 0D7H 00000000 0C8H 0CFH 0C0H 0C7H IP SADEN 0B8H 0BFH X0X00000 00000000 P3 IPH 0B0H 0B7H 11111111 X0X00000 IE SADDR 0A8H 0AFH 00X00000 00000000 0A0H 0A7H SCON SBUF 98H 9FH 00000000 XXXXXXXX P1 ACSR 90H 97H 11111111 XXX00000 TCON TMOD TL0 TL1 TH0 TH1 CLKREG 88H 8FH 00000000 00000000 00000000 00000000 00000000 00000000 XXXXXX0X SP DPL DPH PCON 80H 87H 00000111 00000000 00000000 000X0000 AT89S2051/S4051 6 3390E–MICRO–6/08

AT89S2051/S4051 8. Restrictions on Certain Instructions The AT89S2051/S4051 is an economical and cost-effective member of Atmel’s family of micro- controllers. It contains 2K/4K bytes of Flash program memory. It is fully compatible with the MCS-51 architecture, and can be programmed using the MCS-51 instruction set. However, there are a few considerations one must keep in mind when utilizing certain instructions to pro- gram this device. All the instructions related to jumping or branching should be restricted such that the destination address falls within the physical program memory space of the device, which is 2K/4K for the AT89S2051/S4051. This should be the responsibility of the software programmer. For example, LJMP 7E0H would be a valid instruction for the AT89S2051 (with 2K of memory), whereas LJMP 900H would not. 8.1 Branching Instructions LCALL, LJMP, ACALL, AJMP, SJMP, JMP @A+DPTR. These unconditional branching instructions will execute correctly as long as the programmer keeps in mind that the destination branching address must fall within the physical boundaries of the program memory size (loca- tions 00H to 7FFH/FFFH for the AT89S2051/S4051). Violating the physical space limits may cause unknown program behavior. CJNE [...], DJNZ [...], JB, JNB, JC, JNC, JBC, JZ, JNZ. With these conditional branching instructions, the same rule above applies. Again, violating the memory boundaries may cause erratic execution. For applications involving interrupts, the normal interrupt service routine address locations of the 80C51 family architecture have been preserved. 8.2 MOVX-related Instructions, Data Memory The AT89S2051/S4051 contains 256 bytes of internal data memory. External DATA memory access is not supported in this device, nor is external PROGRAM memory execution. Therefore, no MOVX [...] instructions should be included in the program. A typical 80C51 assembler will still assemble instructions, even if they are written in violation of the restrictions mentioned above. It is the responsibility of the user to know the physical features and limitations of the device being used and adjust the instructions used accordingly. 9. Program Memory Lock Bits On the chip are two lock bits which can be left unprogrammed (U) or can be programmed (P) to obtain the additional features listed in Table 9-1: Table 9-1. Lock Bit Protection Modes(1) Program Lock Bits LB1 LB2 Protection Type 1 U U No program lock features. 2 P U Further programming of the Flash is disabled. 3 P P Same as mode 2, also verify is disabled. Note: 1. The Lock Bits can only be erased with the Chip Erase operation. 7 3390E–MICRO–6/08

10. Reset During reset, all I/O Registers are set to their initial values, the port pins are weakly pulled to V , and the program starts execution from the Reset Vector, 0000H. The AT89S2051/S4051 CC has three sources of reset: power-on reset, brown-out reset, and external reset. 10.1 Power-On Reset A Power-On Reset (POR) is generated by an on-chip detection circuit. The detection level is nominally 1.4V. The POR is activated whenever V is below the detection level. The POR cir- CC cuit can be used to trigger the start-up reset or to detect a supply voltage failure in devices without a brown-out detector. The POR circuit ensures that the device is reset from power-on. When V reaches the Power-on Reset threshold voltage, the Pierce Oscillator is enabled (if the CC XTAL Oscillator Bypass fuse is OFF). Only after V has also reached the BOD (brown-out CC detection) level (see Section 10.2 ”Brown-out Reset”), the BOD delay counter starts measuring a 2-ms delay after which the Internal Reset is deasserted and the microcontroller starts executing. The built-in 2-ms delay allows the V voltage to reach the minimum 2.7V level before execut- CC ing, thus guaranteeing the maximum operating clock frequency. The POR signal is activated again, without any delay, when V falls below the POR threshold level. A Power-On Reset (i.e. CC a cold reset) will set the POF flag in PCON. Refer to Figure 10-1 for details on the POR/BOD behavior. Figure 10-1. Power-up and Brown-out Detection Sequence V CC Min V Level 2.7V CC BOD Level 2.3V POR Level 1.4V t POR t 2.4V XTAL1 1.2V t BOD t Internal RESET t t t POR POR POR (2 ms) (2 ms) (2 ms) t 0 AT89S2051/S4051 8 3390E–MICRO–6/08

AT89S2051/S4051 10.2 Brown-out Reset The AT89S2051/S4051 has an on-chip Brown-out Detection (BOD) circuit for monitoring the V CC level during operation by comparing it to a fixed trigger level. The trigger level for the BOD is nominally 2.0V. The purpose of the BOD is to ensure that if V fails or dips while executing at CC speed, the system will gracefully enter reset without the possibility of errors induced by incorrect execution. When V decreases to a value below the trigger level, the Brown-out Reset is imme- CC diately activated. When V increases above the trigger level, the BOD delay counter starts the CC microcontroller after the timeout period has expired in approximately 2 ms. 10.3 External Reset The RST pin functions as an active-high reset input. The pin must be held high for at least two machine cycles to trigger the internal reset. RST also serves as the In-System Programming (ISP) enable input. ISP mode is enabled when the external reset pin is held high and the ISP Enable fuse is set. 11. Clock Register . Table 11-1. CLKREG – Clock Register CLKREG = 8FH Reset Value = XXXX XX0XB Not Bit Addressable – – – – – – PWDEX X2 Bit 7 6 5 4 3 2 1 0 Symbol Function Power-down Exit Mode. When PWDEX = 1, wake up from Power-down is externally controlled. When PWDEX = 0, wake PWDEX up from Power-down is internally timed. When X2 = 0, the frequency (at XTAL1 pin) is internally divided by 2 before it is used as the device system frequency. When X2 = 1, the divide by 2 is no longer used and the XTAL1 frequency becomes the device system frequency. This X2 enables the user to use a 6 MHz crystal instead of a 12 MHz crystal in order to reduce EMI. The X2 bit is initialized on power-up with the value of the X2 user fuse and may be changed at runtime by software. 9 3390E–MICRO–6/08

12. Power Saving Modes The AT89S2051/S4051 supports two power-reducing modes: Idle and Power-down. These modes are accessed through the PCON register. 12.1 Idle Mode Setting the IDL bit in PCON enters idle mode. Idle mode halts the internal CPU clock. The CPU state is preserved in its entirety, including the RAM, stack pointer, program counter, program status word, and accumulator. The Port pins hold the logical states they had at the time that Idle was activated. Idle mode leaves the peripherals running in order to allow them to wake up the CPU when an interrupt is generated. Timer 0, Timer 1, and the UART will continue to function during Idle mode. The analog comparator is disabled during Idle. Any enabled interrupt source or reset may terminate Idle mode. When exiting Idle mode with an interrupt, the interrupt will immediately be serviced, and following RETI, the next instruction to be executed will be the one following the instruction that put the device into Idle. P1.0 and P1.1 should be set to “0” if no external pull-ups are used, or set to “1” if external pull- ups are used. 12.2 Power-down Mode Setting the PD bit in PCON enters Power-down mode. Power-down mode stops the and powers down the Flash memory in order to minimize power consumption. Only the power-on circuitry will continue to draw power during Power-down. During Power-down the power supply voltage may be reduced to the RAM keep-alive voltage. The RAM contents will be retained; however, the SFR contents are not guaranteed once V has been reduced. Power-down may be exited CC by external reset, power-on reset, or certain interrupts. The user should not attempt to enter (or re-enter) the power-down mode for a minimum of 4 µs until after one of the following conditions has occurred: Start of code execution (after any type of reset), or Exit from power-down mode. 12.3 Interrupt Recovery from Power-down Two external interrupts may be configured to terminate Power-down mode. External interrupts INT0 (P3.2) and INT1 (P3.3) may be used to exit Power-down. To wake up by external interrupt INT0 or INT1, the interrupt must be enabled and configured for level-sensitive operation. When terminating Power-down by an interrupt, two different wake up modes are available. When PWDEX in CLKREG.2 is zero, the wake up period is internally timed. At the falling edge on the interrupt pin, Power-down is exited, the is restarted, and an internal timer begins count- ing. The internal clock will not be allowed to propagate and the CPU will not resume execution until after the timer has counted for nominally 2 ms. After the timeout period the interrupt service routine will begin. To prevent the interrupt from re-triggering, the ISR should disable the interrupt before returning. The interrupt pin should be held low until the device has timed out and begun executing. When PWDEX = 1 the wakeup period is controlled externally by the interrupt. Again, at the fall- ing edge on the interrupt pin, Power-down is exited and the is restarted. However, the internal clock will not propagate and CPU will not resume execution until the rising edge of the interrupt pin. After the rising edge on the pin, the interrupt service routine will begin. The interrupt should be held low long enough for the to stabilize. AT89S2051/S4051 10 3390E–MICRO–6/08

AT89S2051/S4051 12.4 Reset Recovery from Power-down Wakeup from Power-down through an external reset is similar to the interrupt with PWDEX = 0. At the rising edge of RST, Power-down is exited, the is restarted, and an internal timer begins counting. The internal clock will not be allowed to propagate to the CPU until after the timer has counted for nominally 2 ms. The RST pin must be held high for longer than the timeout period to ensure that the device is reset properly. The device will begin executing once RST is brought low. It should be noted that when idle is terminated by a hardware 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. P1.0 and P1.1 should be set to “0” if no external pull-ups are used, or set to “1” if external pull- ups are used. . Table 12-1. PCON – Power Control Register PCON = 87H Reset Value = 000X 0000B Not Bit Addressable SMOD1 SMOD0 PWMEN POF GF1 GF0 PD IDL Bit 7 6 5 4 3 2 1 0 Symbol Function SMOD1 Double Baud Rate bit. Doubles the baud rate of the UART in modes 1, 2, or 3. Frame Error Select. When SMOD0 = 0, SCON.7 is SM0. When SMOD0 = 1, SCON.7 is FE. Note that FE will be set after SMOD0 a frame error regardless of the state of SMOD0. Pulse Width Modulation Enable. When PWMEN = 1, Timer 0 and Timer 1 are configured as an 8-bit PWM counter with PWMEN 8-bit auto-reload prescaler. The PWM outputs on T1 (P3.5). Power Off Flag. POF is set to “1” during power up (i.e. cold reset). It can be set or reset under software control and is not POF affected by RST or BOD (i.e. warm resets). GF1, GF0 General-purpose Flags PD Power Down bit. Setting this bit activates power down operation. IDL Idle Mode bit. Setting this bit activates idle mode operation 11 3390E–MICRO–6/08

13. Interrupts The AT89S2051/S4051 provides 6 interrupt sources: two external interrupts, two timer inter- rupts, a serial port interrupt, and an analog comparator interrupt. These interrupts and the system reset each have a separate program vector at the start of the program memory space. Each interrupt source can be individually enabled or disabled by setting or clearing a bit in the interrupt enable register IE. The IE register also contains a global disable bit, EA, which disables all interrupts. Each interrupt source can be individually programmed to one of four priority levels by setting or clearing bits in the interrupt priority registers IP and IPH. An interrupt service routine in progress can be interrupted by a higher priority interrupt, but not by another interrupt of the same or lower priority. The highest priority interrupt cannot be interrupted by any other interrupt source. If two requests of different priority levels are pending at the end of an instruction, the request of higher priority level is serviced. If requests of the same priority level are pending at the end of an instruction, an internal polling sequence determines which request is serviced. The polling sequence is based on the vector address; an interrupt with a lower vector address has higher priority than an interrupt with a higher vector address. Note that the polling sequence is only used to resolve pending requests of the same priority level. The External Interrupts INT0 and INT1 can each be either level-activated or transition-activated, depending on bits IT0 and IT1 in Register TCON. The flags that actually generate these inter- rupts are the IE0 and IE1 bits in TCON. When the service routine is vectored to, hardware clears the flag that generated an external interrupt only if the interrupt was transition-activated. If the interrupt was level activated, then the external requesting source (rather than the on-chip hard- ware) controls the request flag. The Timer 0 and Timer 1 Interrupts are generated by TF0 and TF1, which are set by a rollover in their respective Timer/Counter registers (except for Timer 0 in Mode 3). When a timer interrupt is generated, the on-chip hardware clears the flag that generated it when the service routine is vectored to. The Serial Port Interrupt is generated by the logical OR of RI and TI in SCON. Neither of these flags is cleared by hardware when the service routine is vectored to. In fact, the service routine normally must determine whether RI or TI generated the interrupt, and the bit must be cleared in software. The CF bit in ACSR generates the Comparator Interrupt. The flag is not cleared by hardware when the service routine is vectored to and must be cleared by software. Most of the bits that generate interrupts can be set or cleared by software, with the same result as though they had been set or cleared by hardware. That is, interrupts can be generated and pending interrupts can be canceled in software. Interrupt Source Vector Address System Reset RST or POR or BOD 0000H External Interrupt 0 IE0 0003H Timer 0 Overflow TF0 000BH External Interrupt 1 IE1 0013H Timer 1 Overflow TF1 001BH Serial Port RI or TI 0023H Analog Comparator CF 0033H AT89S2051/S4051 12 3390E–MICRO–6/08

AT89S2051/S4051 14. Interrupt Registers Table 14-1. IE – Interrupt Enable Register IE = A8H Reset Value = 00X0 0000B Bit Addressable EA EC – ES ET1 EX1 ET0 EX0 Bit 7 6 5 4 3 2 1 0 Symbol Function Global enable/disable. All interrupts are disabled when EA = 0. When EA = 1, each interrupt source is enabled/disabled EA by setting/clearing its own enable bit. EC Comparator Interrupt Enable ES Serial Port Interrupt Enable ET1 Timer 1 Interrupt Enable EX1 External Interrupt 1 Enable ET0 Timer 0 Interrupt Enable EX0 External Interrupt 0 Enable . Table 14-2. IP – Interrupt Priority Register IP = B8H Reset Value = X0X0 0000B Bit Addressable – PC – PS PT1 PX1 PT0 PX0 Bit 7 6 5 4 3 2 1 0 Symbol Function PC Comparator Interrupt Priority Low PS Serial Port Interrupt Priority Low PT1 Timer 1 Interrupt Priority Low PX1 External Interrupt 1 Priority Low PT0 Timer 0 Interrupt Priority Low PX0 External Interrupt 0 Priority Low Table 14-3. IPH – Interru.pt Priority High Register IPH = B7H Reset Value = X0X0 0000B Not Bit Addressable – PCH – PSH PT1H PX1H PT0H PX0H Bit 7 6 5 4 3 2 1 0 Symbol Function PCH Comparator Interrupt Priority High PSH Serial Port Interrupt Priority High PT1H Timer 1 Interrupt Priority High PX1H External Interrupt 1 Priority High PT0H Timer 0 Interrupt Priority High PX0H External Interrupt 0 Priority High 13 3390E–MICRO–6/08

15. Timer/Counters The AT89S2051/S4051 have two 16-bit Timer/Counters: Timer 0 and Timer 1. The Timer/Coun- ters are identical to those in the AT89C2051/C4051. For more detailed information on the Timer/Counter operation, please click on the document link below: http://www.atmel.com/dyn/resources/prod_documents/DOC4316.PDF 16. Pulse Width Modulation Timer 0 and Timer 1 may be configured as an 8-bit pulse width modulator by setting the PWMEN bit in PCON. The generated waveform is output on the Timer 1 input pin, T1. In PWM mode Timer 0 acts as an 8-bit prescaler to select the PWM timebase. Timer 0 is forced into Mode 2 (8- bit auto-reload) by PWMEN and the value in TH0 will determine the clock division from 0 (FFh) to 256 (00h). Timer 1 acts as the 8-bit PWM counter. TL1 counts once on every overflow from TL0. TH1 stores the 8-bit pulse width value. On the FFh-->00h overflow of TL1, the PWM output is set high. When the count in TL1 matches the value in TH1, the PWM output is set low. There- fore, the output pulse width is proportional to the value in TH1. To prevent glitches, writes to TH1 only take effect on the FFh-->00h overflow of TL1. However, a read from TH1 will read the new value at any time after a write to TH1. See Figure 16-1 for PWM waveform example. Figure 16-1. Pulse Width Modulation (PWM) Output Waveform Counter Value (TL1) Compare Value (TH1) PWM Output (T1) Figure 16-2. Timer 0/1 Pulse Width Modulation Mode TH1 TH0 OCR =? P3.5 PWM OSC ÷÷12 TL0 TL1 TL0 counts once every machine cycle (1 machine cycle = 12 clocks in X1 mode) and TH0 is the reload value for when TL0 overflows. Every time TL0 overflows TL1 increments by one, with TL0 overflowing after counting 256 minus TH0 machine cycles. To calculate the pulse width for the PWM output on pin T1, users should use the following formula: TH1 * (256 - TH0) * (1/clock_freq) * 12 = Pulse Width AT89S2051/S4051 14 3390E–MICRO–6/08

AT89S2051/S4051 TL1 will always count from 00h to FFh. The output on the Timer 1 (T1) pin will be high from when TL1 equals 00h until TL1 equals TH1 (see Figure 16-3). TH1 does not act as the reload value for TL1 on overflow. Instead, TH1 is used strictly as a compare value (see Figure 16-2). Figure 16-3. Example of a PWM Output TL1 Count 00 01 10 . . . TH1 . . . FF 00 . . . T1 17. UART The UART in the AT89S2051/S4051 operates the same way as the UART in the AT89C2051/C4051. For more detailed information on the UART operation, please click on the document link below: http://www.atmel.com/dyn/resources/prod_documents/DOC4316.PDF 17.1 Enhanced UART In addition to all of its usual modes, the UART can perform framing error detection by looking for missing stop bits, and automatic address recognition. The UART also fully supports multiproces- sor communication as does the standard 80C51 UART. When used for framing error detect, the UART looks for missing stop bits in the communication. A missing bit will set the FE bit in the SCON register. The FE bit shares the SCON.7 bit with SM0 and the function of SCON.7 is determined by PCON.6 (SMOD0). If SMOD0 is set then SCON.7 functions as FE. SCON.7 functions as SM0 when SMOD0 is cleared. When used as FE, SCON.7 can only be cleared by software. 17.2 Automatic Address Recognition Automatic Address Recognition is a feature which allows the UART to recognize certain addresses in the serial bit stream by using hardware to make the comparisons. This feature saves a great deal of software overhead by eliminating the need for the software to examine every serial address which passes by the serial port. This feature is enabled by setting the SM2 bit in SCON. In the 9-bit UART modes, mode 2 and mode 3, the Receive Interrupt flag (RI) will be automatically set when the received byte contains either the “Given” address or the “Broad- cast” address. The 9-bit mode requires that the 9th information bit is a 1 to indicate that the received information is an address and not data. The 8-bit mode is called mode 1. In this mode the RI flag will be set if SM2 is enabled and the information received has a valid stop bit following the 8 address bits and the information is either a Given or Broadcast address. Mode 0 is the Shift Register mode and SM2 is ignored. Using the Automatic Address Recognition feature allows a master to selectively communicate with one or more slaves by invoking the given slave address or addresses. All of the slaves may be contacted by using the Broadcast address. Two special Function Registers are used to define the slave’s address, SADDR, and the address mask, SADEN. SADEN is used to define which bits in the SADDR are to be used and which bits are “don’t care”. The SADEN mask can 15 3390E–MICRO–6/08

be logically ANDed with the SADDR to create the “Given” address which the master will use for addressing each of the slaves. Use of the Given address allows multiple slaves to be recognized while excluding others. The following examples will help to show the versatility of this scheme: Slave 0 SADDR = 1100 0000 SADEN = 1111 1101 Given = 1100 00X0 Slave 1 SADDR = 1100 0000 SADEN = 1111 1110 Given = 1100 000X In the previous example SADDR is the same and the SADEN data is used to differentiate between the two slaves. Slave 0 requires a 0 in bit 0 and it ignores bit 1. Slave 1 requires a 0 in bit 1 and bit 0 is ignored. A unique address for slave 0 would be 1100 0010 since slave 1 requires a 0 in bit 1. A unique address for slave 1 would be 1100 0001 since a 1 in bit 0 will exclude slave 0. Both slaves can be selected at the same time by an address which has bit 0 = 0 (for slave 0) and bit 1 = 0 (for slave 1). Thus, both could be addressed with 1100 0000. In a more complex system the following could be used to select slaves 1 and 2 while excluding slave 0: Slave 0 SADDR = 1100 0000 SADEN = 1111 1001 Given = 1100 0XX0 Slave 1 SADDR = 1110 0000 SADEN = 1111 1010 Given = 1110 0X0X Slave 2 SADDR = 1110 0000 SADEN = 1111 1100 Given = 1110 00XX In the above example the differentiation among the 3 slaves is in the lower 3 address bits. Slave 0 requires that bit 0 = 0 and it can be uniquely addressed by 1110 0110. Slave 1 requires that bit 1 = 0 and it can be uniquely addressed by 1110 and 0101. Slave 2 requires that bit 2 = 0 and its unique address is 1110 0011. To select Slaves 0 and 1 and exclude Slave 2, use address 1110 0100, since it is necessary to make bit 2 = 1 to exclude slave 2. The Broadcast Address for each slave is created by taking the logical OR of SADDR and SADEN. Zeros in this result are trended as don’t cares. In most cases, interpreting the don’t cares as ones, the broadcast address will be FF hexadecimal. Upon reset SADDR (SFR address 0A9H) and SADEN (SFR address 0B9H) are loaded with 0s. This produces a given address of all “don’t cares” as well as a Broadcast address of all “don’t cares”. This effectively disables the Automatic Addressing mode and allows the microcontroller to use standard 80C51-type UART drivers which do not make use of this feature. AT89S2051/S4051 16 3390E–MICRO–6/08

AT89S2051/S4051 Table 17-1. SCON – Serial Port Control Register SCON Address = 98H Reset Value = 0000 0000B Bit Addressable SM0/FE SM1 SM2 REN TB8 RB8 TI RI Bit 7 6 5 4 3 2 1 0 (SMOD = 0/1)(1) Symbol Function Framing error bit. This bit is set by the receiver when an invalid stop bit is detected. The FE bit is not cleared by valid FE frames but should be cleared by software. The SMOD0 bit must be set to enable access to the FE bit. FE will be set regardless of the state of SMOD. SM0 Serial Port Mode Bit 0, (SMOD must = 0 to access bit SM0) Serial Port Mode Bit 1 SM0 SM1 Mode Description Baud Rate(2) 0 0 0 shift register f /12 osc SM1 0 1 1 8-bit UART variable 1 0 2 9-bit UART f /64 or f /32 osc osc 1 1 3 9-bit UART variable Enables the Automatic Address Recognition feature in modes 2 or 3. If SM2 = 1 then Rl will not be set unless the received 9th data bit (RB8) is 1, indicating an address, and the received byte is a Given or Broadcast Address. In mode 1, if SM2 = SM2 1 then Rl will not be activated unless a valid stop bit was received, and the received byte is a Given or Broadcast Address. In Mode 0, SM2 should be 0. REN Enables serial reception. Set by software to enable reception. Clear by software to disable reception. TB8 The 9th data bit that will be transmitted in modes 2 and 3. Set or clear by software as desired. In modes 2 and 3, the 9th data bit that was received. In mode 1, if SM2 = 0, RB8 is the stop bit that was RB8 received. In mode 0, RB8 is not used. Transmit interrupt flag. Set by hardware at the end of the 8th bit time in mode 0, or at the beginning of the TI stop bit in the other modes, in any serial transmission. Must be cleared by software. Receive interrupt flag. Set by hardware at the end of the 8th bit time in mode 0, or halfway through the stop RI bit time in the other modes, in any serial reception (except see SM2). Must be cleared by software. Notes: 1. SMOD is located at PCON.7. 2. f = frequency. osc 17 3390E–MICRO–6/08

18. Analog Comparator A single analog comparator is provided in the AT89S2051/S4051. The comparator operation is such that the output is a logical “1” when the positive input AIN0 (P1.0]) is greater than the neg- ative input AIN1 (P1.1). Otherwise the output is a zero. Setting the CEN bit in ACSR enables the comparator. When the comparator is first enabled, the comparator output and interrupt flag are not guaranteed to be stable for 10 microseconds. The corresponding comparator interrupt should not be enabled during that time, and the comparator interrupt flag must be cleared before the interrupt is enabled in order to prevent an immediate interrupt service. The comparator may be configured to cause an interrupt under a variety of output value condi- tions by setting the CM bits in ACSR. The comparator interrupt flag CF in ACSR is set whenever the comparator output matches the condition specified by CM. The flag may be polled by soft- ware or may be used to generate an interrupt and must be cleared by software. The analog comparator is always disabled during Idle or Power-down modes. 19. Comparator Interrupt with Debouncing The comparator output is sampled at every State 4 (S4) of every machine cycle. The conditions on the analog inputs may be such that the comparator output will toggle excessively. This is especially true if applying slow moving analog inputs. Three debouncing modes are provided to filter out this noise. In debouncing mode, the comparator uses Timer 1 to modulate its sampling time. When a relevant transition occurs, the comparator waits until two Timer 1 overflows have occurred before resampling the output. If the new sample agrees with the expected value, CF is set. Otherwise, the event is ignored. The filter may be tuned by adjusting the timeout period of Timer 1. Because Timer 1 is free running, the debouncer must wait for two overflows to guaran- tee that the sampling delay is at least 1 timeout period. Therefore after the initial edge event, the interrupt may occur between 1 and 2 timeout periods later. See Figure 19-1. Figure 19-1. Example of Negative Edge Comparator Interrupt with Debouncing Comparator Out Timer 1 Overflow CF START COMPARE START COMPARE AT89S2051/S4051 18 3390E–MICRO–6/08

AT89S2051/S4051 20. Analog Comparator Register . Table 20-1. ACSR – Analog Comparator Control & Status Register ACSR = 97H Reset Value = XXX0 0000B Not Bit Addressable – – – CF CEN CM2 CM1 CM0 Bit 7 6 5 4 3 2 1 0 Symbol Function Comparator Interrupt Flag. Set when the comparator output meets the conditions specified by the CM [2:0] bits and CEN CF is set. The flag must be cleared by software. The interrupt may be enabled/disabled by setting/clearing bit 6 of IE. Comparator Enable. Set this bit to enable the comparator. Clearing this bit will force the comparator output low and CEN prevent further events from setting CF. Comparator Interrupt Mode 2 1 0 Interrupt Mode --- ---- ---- --------------------------------------- 0 0 0 Negative (Low) level 0 0 1 Positive edge CM [2:0] 0 1 0 Toggle with debounce 0 1 1 Positive edge with debounce 1 0 0 Negative edge 1 0 1 Toggle 1 1 0 Negative edge with debounce 1 1 1 Positive (High) level 19 3390E–MICRO–6/08

21. Parallel Programming Specification Atmel’s AT89S2051/S4051 offers 2K/4K bytes of In-System Programmable Flash code memory. In addition, the device contains a 32-byte User Signature Row and a 32-byte read-only Atmel Signature Row. Table 21-1. Memory Organization Device # Page Size # Pages Address Range Page Range AT89S2051 32 bytes 64 0000H - 07FFH 00H - 3FH AT89S4051 32 bytes 128 0000H - 0FFFH 00H - 7FH Figure 21-1. Flash Parallel Programming Device Connections AT89S2051/S4051 2.7V to 5.5V V CC RDY/BSY(1) P3.1 P1.7 - P1.0 DATA IN/OUT PROG P3.2 TestCode P3.7-3 INC XTAL1 RST V PP GND Note: 1. Sampling of pin P3.1 (RDY/BSY) is optional. In Parallel Mode, P3.1 will be pulled low while the device is busy. However, it requires an external passive pull-up to V . Also, note that P3.6 CC does not exist, so TestCode connects to P3.7, P3.5, P3.4, and P3.3. AT89S2051/S4051 20 3390E–MICRO–6/08

AT89S2051/S4051 Table 21-2. Parallel Programming Mode Command Summary Test Control Test Selects Data I/O P3.2 INC Mode RST(1) P3.3 P3.4 P3.5 P3.7 P1.7-0 Chip Erase(5) 1.0 µs 12V L H L L L XX Load X-Address(2) H 12V 0.1 µs H L H H D IN Page Write(3)(4)(6) Code Memory 1.0 µs 12V 0.1 µs L H H H D IN Page Read(3) Code Memory H 12V 0.1 µs L L H H D OUT Page Write(3)(4)(6)(7) Sig. Row 1.0 µs 12V 0.1 µs L L L L D IN Page Read(3)(8)(10) Sig. Row H 12V 0.1 µs L L L H D OUT Write Fuse/Lock Bit(5)(9) 1.0 µs 12V L H H H H D IN Read Fuse/Lock Bit(9) H 12V L H H L L D OUT Notes: 1. The internal Y-address counter is reset to 00H on the rising/falling edge of RST. 2. A positive pulse on XTAL1 loads the address data on Port P1 into the X-address (page) register and resets the Y-address. 3. A positive pulse on XTAL1 advances the Y-address counter. 4. A low pulse on P3.2 loads data from Port P1 for the current address. If another P3.2 low pulse does not arrive within 150 µs, programming starts. 5. Internally timed for 4 ms. 6. Internally timed for 2 ms. 7. 00H must be loaded into the X-address before executing this command. 8. Will read User Signature if X-address is 00H, will read Atmel Signature if X-address is 01H. 9. Fuse/Lock Bit Definitions: Bit 7 XTAL Osc Bypass Enable = 0/Disable = 1 Bit 6 User Row Programming Enable = 0/Disable = 1 Bit 5 x2 Clock Enable = 0/Disable = 1 Bit 4 Serial Programming Enable = 0/Disable = 1 Bit 1 Lock Bit 2 Locked = 0/Unlocked = 1 Bit 0 Lock Bit 1 Locked = 0/Unlocked = 1 10.Atmel Signature Bytes: AT89S2051: Address 00H = 1EH 01H = 23H 02H = FFH AT89S4051: Address 00H = 1EH 01H = 43H 02H = FFH 21 3390E–MICRO–6/08

22. Power-up Sequence Execute the following sequence to power-up the device before programming. 1. Apply power between VCC and GND pins. 2. After V has settled, wait 10 µs and bring RST to “H”. CC 3. Wait 4 ms for the internal Power-on Reset to timeout. 4. Bring P3.2 to “H” and drive P3.7, P3.5, P3.4, and P3.3 to known values, then wait 10 µs. 5. Raise RST/V to 12V to enable the parallel programming modes. PP 6. After V has settled, wait an additional 10 µs before programming. PP Figure 22-1. Power-up Operation V CC RST/V PP P3.2 XTAL1 P3.3 - P3.7 High Z P1.0 - P1.7 High Z RDY/BSY High Z 23. Power-down Sequence Execute the following sequence to power-down the device after programming. 1. Tri-state Port P1. 2. Bring RST/V down from 12V to V and wait 10 µs. PP CC 3. Bring XTAL and P3.2 to “L” and tri-state P3.7, P3.5, P3.4, and P3.3. 4. Bring RST to “L” and wait 10 µs. 5. Power off V . CC Figure 23-1. Power-down Operation V CC RST/V PP P3.2 XTAL1 P3.3 - P3.7 High Z P1.0 - P1.7 High Z RDY/BSY High Z AT89S2051/S4051 22 3390E–MICRO–6/08

AT89S2051/S4051 24. Chip Erase Function: 1. FFH programmed to every address location. 2. FFH programmed to User Signature Row if User Row Fuse bit is enabled. 3. Lockbit1 and Lockbit2 programmed to “unlock” state. Usage: 1. Apply “0001” TestCode to P3.7, P3.5, P3.4, P3.3. 2. Pulse P3.2 low for 1 µs. 3. Wait 4 ms, monitor P3.1, or poll data. Note: This and the following waveforms are not to scale. Figure 24-1. Chip Erase Sequence P3.2 XTAL1 P3.3 - P3.7 0001 P1.0 - P1.7 High Z RDY/BSY 25. Load X-Address Function: 1. Loads the X-Address register with data on Port P1. The loaded address will select the page for subsequent write/read commands. The X-Address is equivalent to bits [11:5] of the full byte address. 2. Resets the Y-Address counter to 00H. The Y-Address is equivalent to bits [4:0] of the full byte address and selects a byte within a page. Usage: 1. Apply “1101” TestCode to P3.7, P3.5, P3.4, P3.3. 2. Drive Port P1 with 8-bit X-address data. 3. Pulse XTAL1 high for at least 100 ns. The address is latched on the falling edge of XTAL1. Figure 25-1. Load X-Address Sequence P3.2 XTAL1 P3.3 - P3.7 1101 P1.0 - P1.7 High Z XADDR High Z RDY/BSY 23 3390E–MICRO–6/08

26. Page Write 4K Code Function: 1. Programs 1 page (1 to 32 bytes) of data into the Code Memory array. 2. X-address (page) determined by previous Load-X command. 3. Y-address (offset) incremented by positive pulse on XTAL1. 4. 1 byte of data is loaded from Port P1 for the current X- and Y-address by a low pulse on P3.2. Usage: 1. Execute the Load-X command to set the page address and reset the offset. 2. Apply “1110” TestCode to P3.7, P3.5, P3.4, P3.3. 3. Drive Port P1 with 8-bit data. 4. Pulse P3.2 low for 1 µs to load the data from Port P1. 5. For additional bytes (up to 32), pulse XTAL1 high for at least 100 ns to increment the Y-address and repeat steps 3 and 4 within 150 µs. 6. Wait 2 ms, monitor P3.1, or poll data. Note: It is possible to skip bytes by pulsing XTAL1 high multiple times before pulsing P3.2 low. Figure 26-1. Page Write 4K Code Programming Sequence P3.2 XTAL1 P3.3 - P3.7 1101 1110 P1.0 - P1.7 XADDR DIN0 DIN1 DIN N-1 High Z RDY/BSY AT89S2051/S4051 24 3390E–MICRO–6/08

AT89S2051/S4051 27. Read 4K Code Function: 1. Read 1 page (1 to 32 bytes) of data from the Code Memory array. 2. X-address (page) determined by previous Load-X command. 3. Y-address (offset) incremented by positive pulse on XTAL1. Usage: 1. Execute the Load-X command to set the page address and reset the offset. 2. Apply “1100” TestCode to P3.7, P3.5, P3.4, P3.3. 3. Read 8-bit data on Port P1. 4. For additional bytes (up to 32), pulse XTAL1 high for at least 100 ns to increment the Y-address and repeat step 3. The address will change on the falling edge of XTAL1. Figure 27-1. Read 4K Code Programming Sequence P3.2 XTAL1 P3.3 - P3.7 1101 1100 P1.0 - P1.7 XADDR DOUT0 DOUT1 DOUT N-1 RDY/BSY 25 3390E–MICRO–6/08

28. Page Write User Signature Row Function: 1. Programs 1 to 32 bytes of data into the User Signature Row. 2. X-address (page) should be 00H from a previous Load-X command. 3. Y-address (offset) incremented by positive pulse on XTAL1. 4. 1 byte of data is loaded from Port P1 for the current Y-address by a low pulse on P3.2. 5. Disabled if User Row Fuse bit is disabled. Usage: 1. Execute the Load-X command to set the page to 00H and reset the offset. 2. Apply “0000” TestCode to P3.7, P3.5, P3.4, P3.3. 3. Drive Port P1 with 8-bit data. 4. Pulse P3.2 low for 1 µs to load the data from Port P1. 5. For additional bytes (up to 32), pulse XTAL1 high for at least 100 ns to increment the Y- address and repeat steps 3 and 4 within 150 µs. 6. Wait 2 ms, monitor P3.1, or poll data. Note: It is possible to skip bytes by pulsing XTAL1 high multiple times before pulsing P3.2 low. Figure 28-1. Page Write User Signature Row Sequence P3.2 XTAL1 P3.3 - P3.7 1101 0000 P1.0 - P1.7 00H DIN0 DIN1 DIN N-1 RDY/BSY AT89S2051/S4051 26 3390E–MICRO–6/08

AT89S2051/S4051 29. Read User Signature Row Function: 1. Reads 1 to 32 bytes of data from the User Signature Row. 2. X-address (page) should be 00H from a previous Load-X command. 3. Y-address (offset) incremented by positive pulse on XTAL1. Usage: 1. Execute the Load-X command to set the page to 00H and reset the offset. 2. Apply “1000” TestCode to P3.7, P3.5, P3.4, P3.3. 3. Read 8-bit data on Port P1. 4. For additional bytes (up to 32), pulse XTAL1 high for at least 100 ns to increment the Y- address and repeat step 3. The address will change on the falling edge of XTAL1. Figure 29-1. Read User Signature Row Sequence P3.2 XTAL1 P3.3 - P3.7 1101 1000 P1.0 - P1.7 00H DOUT0 DOUT1 DOUT N-1 RDY/BSY 27 3390E–MICRO–6/08

30. Read Atmel Signature Row Function: 1. Reads 1 to 32 bytes of data from the Atmel Signature Row. 2. X-address (page) should be 01H from a previous Load-X command. 3. Y-address (offset) incremented by positive pulse on XTAL1. Usage: 1. Execute the Load-X command to set the page to 01H and reset the offset. 2. Apply “1000” TestCode to P3.7, P3.5, P3.4, P3.3. 3. Read 8-bit data on Port P1. 4. For additional bytes (up to 32), pulse XTAL1 high for at least 100 ns to increment the Y- address and repeat step 3. The address will change on the falling edge of XTAL1. Figure 30-1. Read Atmel Signature Row Sequence P3.2 XTAL1 P3.3 - P3.7 1101 1000 P1.0 - P1.7 01H DOUT0 DOUT1 DOUT N-1 RDY/BSY AT89S2051/S4051 28 3390E–MICRO–6/08

AT89S2051/S4051 31. Write Lock Bits/User Fuses Function: 1. Program Lock Bits 1 and 2. 2. Program user fuses. Usage: 1) Apply “1111” TestCode to P3.7, P3.5, P3.4, P3.3. 3. Drive Port P1 with fuse data, bits [7:4] for fuses and bits [1:0] for lock bits. 4. Pulse P3.2 low for 1 µs. 5. Wait 4 ms, monitor P3.1, or poll data. Figure 31-1. Write Lock Bits/User Fuses P3.2 XTAL1 P3.3 - P3.7 1111 P1.0 - P1.7 High Z DATA High Z RDY/BSY 32. Read Lock Bits/User Fuses Function: 1. Read status of Lock Bits 1 and 2. 2. Read status of user fuses. Usage: 1. Apply “0011” TestCode to P3.7, P3.5, P3.4, P3.3. 2. Read fuse data from Port P1, bits [7:4] for fuses and bits [1:0] for lock bits. Figure 32-1. Read Lock Bits/User Fuses P3.2 XTAL1 P3.3. - P3.7 0011 P1.0 - P1.7 High Z DOUT High Z RDY/BSY 29 3390E–MICRO–6/08

Figure 32-2. Flash Programming and Verification Waveforms in Parallel Mode (RDY/BSY)P3.1 XTAL1 PORT0 P3.3...P3.7 P3.2/PROG RST/VPP VCC POt PWt R R U P ASTPt PSTPt HSTLt X L A O XTWt DDR ADX MSTPt At H L D D A T XLPt A0 DSTPt PGWt D A T A 1 PHXt DATA DHLDt PAGE W BLTt N R IT Pt E H B L Wt C Mt S T P X A D LO D A R D X Mt D HLD ATA 0 RDTt DATA PAGE R 1 E A D Vt F D Y A T A N Ht S T L Pt W R D N AT89S2051/S4051 30 3390E–MICRO–6/08

AT89S2051/S4051 Table 32-1. Parallel Flash Programming and Verification Parameters Symbol Parameter Min Max Units V Programming Enable Voltage 11.5 12.5 V PP I Programming Enable Current 1.0 mA PP t Power-on to RST High 10 µs PWRUP t Power-on Reset Time 2 ms POR t PROG Setup to V High 10 µs PSTP PP t High Voltage Setting time 10 µs HSTL t Mode Setup to PROG or XTAL1 1 µs MSTP t Mode Hold after PROG or XTAL2 1 µs MHLD t XTAL1 High Width 0.5 µs XTW t Address Setup to XTAL1 High 0.5 µs ASTP t Address Hold after XTAL1 Low 0.5 µs AHLD t PROG Low Width 1 µs PGW t Data Setup to PROG Low 0.5 µs DSTP t Data Hold after PROG High 0.5 µs DHLD t XTAL1 Low to PROG Low 0.5 µs XLP t PROG High to XTAL1 High 0.5 µs PHX t Byte Load Period 150 µs BLT t PROG High to BUSY Low 256 µs PHBL t Wire Cycle Time 4.5 ms WC t Read Byte Time 1 µs RDT t XTAL1 Low to Data Verify Valid 0.25 µs VFY t RST Low to Power Off 1 µs PWRDN 31 3390E–MICRO–6/08

33. In-System Programming (ISP) Specification Atmel’s AT89S2051/S4051 offers 2K/4K bytes of In-System Programmable Flash code memory. In addition, the device contains a 32-byte User Signature Row and a 32-byte read-only Atmel Signature Row. Table 33-1. Memory Organization Device # Page Size # Pages Address Range Page Range AT89S2051 32 bytes 64 0000H - 07FFH 00H - 3FH AT89S4051 32 bytes 128 0000H - 0FFFH 00H - 7FH Figure 33-1. ISP Programming Device Connections AT89S2051/S4051 2.7V to 5.5V V CC SCK(1) P1.7 P1.6 SERIAL OUT (MISO) SERIAL IN P1.5 (MOSI) XTAL1 RST V CC GND Note: 1. SCK frequency should be less than (XTAL frequency)/8. AT89S2051/S4051 32 3390E–MICRO–6/08

AT89S2051/S4051 34. Serial Programming Command Summary Command Byte 1 Byte 2 Byte 3 Byte 4 Byte ... Program Enable(1) 1010 1100 0101 0011 xxxx xxxx xxxx xxxx Chip Erase 1010 1100 100x xxxx xxxx xxxx xxxx xxxx Write Code Byte 0100 0000 xxxx 11 10 98 76543210 7654 3210 AAAA AAAAAAAA DDDD DDDD Read Code Byte 0010 0000 xxxx 11 109 8 A7A6A5A4A3A2A1A0 D7D6D5D4 D3D2D1D0 AAAA Write Code Page(2) 0101 0000 xxxx 11 109 8 7 6 5 0 0000 Data 0 ... Data 31 AAAA AAA Read Code Page(2) 0011 0000 xxxx 11 109 8 7 6 5 0 0000 Data 0 ... Data 31 AAAA AAA Write User Fuses(3) 1010 1100 0001 3 21 0 xxxx xxxx xxxx xxxx FFFF Read User Fuses(3) 0010 0001 xxxx xxxx xxxx xxxx xxxx F3 F2F1 F0 1110 0x2 1 Write Lock Bits(4) 1010 1100 BB xxxx xxxx xxxx xxxx LL Read Lock Bits(4) 0010 0100 xxxx xxxx xxxx xxxx xxxx xx B2B1 LL Write User Signature Byte 0100 0010 xxxx xxxx xxxA4 A3A2A1A0 D7D6D5D4 D3D2D1D0 Read User Signature Byte 0010 0010 xxxx xxxx xxx A4A3A2A1A0 D7D6D5D4 D3D2D1D0 Write User Signature Page(2) 0101 0010 xxxx xxxx xxxx xxxx Data 0 ... Data 31 Read User Signature Page(2) 0011 0010 xxxx xxxx xxxx xxxx Data 0 ... Data 31 Read Atmel Signature Byte(5) 0010 1000 xxxx xxxx xxx4 3210 7654 3210 AAAAA DDDD DDDD Notes: 1. Program Enable must be the first command issued after entering into the serial programming mode. 2. All 32 Data bytes must be written/read. 3. Fuse Bit Definitions: Bit 0 ISP Enable* Enable = 0/Disable = 1 Bit 1 x2 Clock Enable = 0/Disable = 1 Bit 2 User Row Programming Enable = 0/Disable = 1 Bit 3 XTAL Osc Bypass** Enable = 0/Disable = 1 *The ISP Enable Fuse must be enabled before entering ISP mode. When disabling the ISP fuse during ISP mode, the current fuse state will remain active until RST is brought low. **Any change will only take effect after the next power-down/power-up cycle event. 4. Lock Bit Definitions: Bit 0 Lock Bit 1 Locked = 0/Unlocked = 1 Bit 1 Lock Bit 2 Locked = 0/Unlocked = 1 5. Atmel Signature Bytes: AT89S2051: Address 00H = 1EH 01H = 23H 02H = FFH AT89S4051: Address 00H = 1EH 01H = 43H 02H = FFH 33 3390E–MICRO–6/08

35. Power-up Sequence Execute this sequence to power-up the device before programming. 1. Apply power between VCC and GND pins. 2. Keep SCK (P1.7) at GND. 3. Wait 10 µs and bring RST to “H”. 4. If a crystal is connected between XTAL1 and XTAL2, wait at least 10 ms; otherwise, apply a 3 - 24 MHz clock to XTAL1 and wait 4 ms. Figure 35-1. ISP Power-up Sequence V CC RST XTAL1 P1.7/SCK P1.6/MISO High Z P1.5/MOSI 36. ISP Start Sequence Execute this sequence to enter ISP when the device is already operational. 1. Bring SCK (P1.7) to GND. 2. Tri-state MISO (P1.6). 3. Bring RST to “H”. Figure 36-1. ISP Start Sequence V CC RST XTAL1 P1.7/SCK P1.6/MISO High Z P1.5/MOSI AT89S2051/S4051 34 3390E–MICRO–6/08

AT89S2051/S4051 37. Power-down Sequence Execute this sequence to power-down the device after programming. 1. Set XTAL1 to “L” if a crystal is not used. 2. Bring RST to “L”. 3. Tri-state MOSI (P1.5). Figure 37-1. ISP Power-down Sequence V CC RST XTAL1 P1.7/SCK P1.6/MISO High Z P1.5/MOSI High Z 38. ISP Byte Sequence 1. Data shifts in/out MSB first. 2. MISO changes at rising of SCK. 3. MOSI is sampled at falling edge of SCK. Figure 38-1. ISP Byte Sequence P1.7/SCK P1.6/MISO 7 6 5 4 3 2 1 0 data is sampled P1.5/MOSI 7 6 5 4 3 2 1 0 39. ISP Command Sequence 1. Byte Format: 4 byte packet (3 header bytes + 1 data byte) 2. Page Format: 35 byte packet (3 header bytes + 32 data bytes) 3. All bytes are required, even if they are don’t care. Figure 39-1. ISP Command Sequence SCK SO 7 ??? 0 7 ??? 0 7 ??? 0 7 DATAOUT 0 SI 7 OPCODE 0 7 ADDRH 0 7 ADDRL 0 7 DATAIN 0 35 3390E–MICRO–6/08

40. Absolute Maximum Ratings* *NOTICE: Stresses beyond those listed under “Absolute Operating Temperature.................................-55°C to +125°C Maximum Ratings” may cause permanent dam- age to the device. This is a stress rating only and Storage Temperature.....................................-65°C to +150°C functional operation of the device at these or any Voltage on Any Pin with Respect to Ground......-0.7V to +6.2V other conditions beyond those indicated in the operational sections of this specification is not Maximum Operating Voltage............................................5.5V implied. Exposure to absolute maximum rating conditions for extended periods may affect DC Output Current.............25.0 mA (15.0 mA for AT89S4051) device reliability. 41. DC Characteristics T = -40°C to 85°C, V = 2.7V to 5.5V (unless otherwise noted) A CC Symbol Parameter Condition Min Max Units V Input Low-voltage -0.5 0.2 V - 0.1 V IL CC V Input High-voltage (Except XTAL1, RST) 0.2 V + 0.9 V + 0.5 V IH CC CC V Input High-voltage (XTAL1, RST) 0.7 V V + 0.5 V IH1 CC CC V Output Low-voltage(1) (Ports 1, 3) I = 10 mA, V = 2.7V, T = 85°C 0.5 V OL OL CC A I = -80 µA, V = 5V ± 10% 2.4 V OH CC V Output High-voltage (Ports 1, 3) I = -30 µA 0.75 V V OH OH CC I = -12 µA 0.9 V V OH CC Logical 0 Input Current I V = 0.45V -50 µA IL (Ports 1, 3) IN Logical 1 to 0 Transition Current I V = 2V, V = 5V ± 10% -350 µA TL (Ports 1, 3) IN CC Input Leakage Current I 0 < V < V ±10 µA LI (Port P1.0, P1.1) IN CC V Comparator Input Offset Voltage V = 5V 20 mV OS CC Comparator Input Common V 0 V V CM Mode Voltage CC RRST Reset Pull-down Resistor 50 150 KΩ C Pin Capacitance Test Freq. = 1 MHz, T = 25°C 10 pF IO A Active Mode, 24/12 MHz, V = CC 10.5/3.5 mA 5V/3V Power Supply Current (without the ) Idle Mode, 24/12 MHz, V = 5V/3V I CC 4.5/2.5 mA CC P1.0 & P1.1 = 0V or V CC V = 5V, P1.0 & P1.1 = 0V or V (3) 10 µA Power-down Mode(2) CC CC V = 3V, P1.0 & P1.1 = 0V or V (3) 5 µA CC CC Notes: 1. Under steady state (non-transient) conditions, I must be externally limited as follows: OL Maximum I per port pin: 10 mA OL Maximum total I for all output pins: 25 mA (15 mA for AT89S4051) OL If I exceeds the test condition, V may exceed the related specification. Pins are not guaranteed to sink current greater OL OL than the listed test conditions. 2. Minimum V for Power-down is 2V. CC 3. P1.0 and P1.1 are comparator inputs and have no internal pullups. They should not be left floating. AT89S2051/S4051 36 3390E–MICRO–6/08

AT89S2051/S4051 42. External Clock Drive Waveforms 43. External Clock Drive V = 2.7V to 5.5V CC Symbol Parameter Min Max Units 1/t Frequency 0 24 MHz CLCL t Clock Period 41.6 ns CLCL t High Time 12 ns CHCX t Low Time 12 ns CLCX t Rise Time 5 ns CLCH t Fall Time 5 ns CHCL 37 3390E–MICRO–6/08

44. Serial Port Tim ing: Shift Register Mode Test Conditions The values in this table are valid for V = 2.7V to 5.5V and Load Capacitance = 80 pF. CC Variable Symbol Parameter Min Max Units t Serial Port Clock Cycle Time 12t -15 µs XLXL CLCL t Output Data Setup to Clock Rising Edge 10t -15 ns QVXH CLCL t Output Data Hold after Clock Rising Edge 2t -15 ns XHQX CLCL t Input Data Hold after Clock Rising Edge t ns XHDX CLCL t Input Data Valid to Clock Rising Edge 0 ns XHDV 45. Shift Register Mode Timing Waveforms 46. AC Testing Input/Output Waveforms(1) Note: 1. AC Inputs during testing are driven at V - 0.5V for a logic 1 and 0.45V for a logic 0. Timing CC measurements are made at V min. for a logic 1 and V max. for a logic 0. IH IL 47. Float Waveforms(1) Note: 1. For timing purposes, a port pin is no longer floating when a 100 mV change from load voltage occurs. A port pin begins to float when 100 mV change from the loaded V /V level occurs. OH OL AT89S2051/S4051 38 3390E–MICRO–6/08

AT89S2051/S4051 48. I Test Condition, Active Mode, All Other Pins are Disconnected CC V CC I CC V RST CC V CC P1, P3 (NC) XTAL2 CLOCK SIGNAL XTAL1 V SS 49. I Test Condition, Idle Mode, All Other Pins are Disconnected CC V CC I CC RST VCC V CC P1, P3 (NC) XTAL2 CLOCK SIGNAL XTAL1 V SS 50. Clock Signal Waveform for I Tests in Active and Idle Modes, CC t = t = 5 ns CLCH CHCL V - 0.5V CC 0.7 V t CC CHCX 0.2 V - 0.1V t 0.45V CC CLCH t t CHCL CHCX t CLCL 51. I Test Condition, Power-down Mode, All Other Pins are Disconnected, CC V = 2V to 5.5V CC V CC I CC RST VCC V CC P1, P3 (NC) XTAL2 XTAL1 VSS 39 3390E–MICRO–6/08

52. I (Active Mode) Measurements CC I Active @ 25oC CC 4.00 A) 3.50 m 3.0V ( 3.00 e v 4.0V cti 2.50 A 5.0V C 2.00 C I 1.50 1 2 3 4 5 6 7 8 9 10 11 12 Frequency (MHz) I Active @ 90oC CC 4.00 A) 3.50 m 3.0 V ( 3.00 e v 4.0 V cti 2.50 A 5.0 V C 2.00 C I 1.50 1 2 3 4 5 6 7 8 9 10 11 12 Frequency (MHz) AT89S2051/S4051 40 3390E–MICRO–6/08

AT89S2051/S4051 53. I (Idle Mode) Measurements CC I Idle vs. Frequency CC T = 25°C 3 2.5 A) 2 Vcc=3V m (1.5 Vcc=4V C C I 1 Vcc=5v 0.5 0 0 5 10 15 20 25 Frequency (MHz) 54. I (Power Down Mode) Measurements CC I in Power-down CC 2.5 2 ) A u 1.5 0 deg C ( d 25 deg C w 1 P 90 deg C C IC 0.5 0 1 2 3 4 5 6 7 V (V) CC 41 3390E–MICRO–6/08

55. Ordering Information 55.1 Green Package Option (Pb/Halide-free) Speed Power (MHz) Supply Ordering Code Package Operation Range AT89S2051/S4051-24PU 20P3 Industrial 24 2.7V to 5.5V AT89S2051/S4051-24SU 20S2 (-40°C to 85°C) Package Type 20P3 20-lead, 0.300” Wide, Plastic Dual In-line Package (PDIP) 20S2 20-lead, 0.300” Wide, Plastic Gull Wing Small Outline (SOIC) AT89S2051/S4051 42 3390E–MICRO–6/08

AT89S2051/S4051 56. Package Information 56.1 20P3 – PDIP D PIN 1 E1 A SEATING PLANE A1 L B B1 e E COMMON DIMENSIONS (Unit of Measure = mm) C SYMBOL MIN NOM MAX NOTE eC eB A – – 5.334 A1 0.381 – – D 24.892 – 26.924 Note 2 E 7.620 – 8.255 E1 6.096 – 7.112 Note 2 B 0.356 – 0.559 B1 1.270 – 1.551 Notes: 1.This package conforms to JEDEC reference MS-001, Variation AD. 2.Dimensions D and E1 do not include mold Flash or Protrusion. L 2.921 – 3.810 Mold Flash or Protrusion shall not exceed 0.25 mm (0.010"). C 0.203 – 0.356 eB – – 10.922 eC 0.000 – 1.524 e 2.540 TYP 1/23/04 TITLE DRAWING NO. REV. 2325 Orchard Parkway 20P3, 20-lead (0.300"/7.62 mm Wide) Plastic Dual R San Jose, CA 95131 Inline Package (PDIP) 20P3 D 43 3390E–MICRO–6/08

56.2 20S2 – SOIC AT89S2051/S4051 44 3390E–MICRO–6/08

AT89S2051/S4051 57. Revision History Revision No. History • Removed Preliminary Status. • Added the qualifier “x1 and x2 Modes” to the Static Operation range. Revision D – Feb. 2007 • Changed the value ranges for Capacitors C1 and C2 in Figure 5-1 on page 4. • Changed the trigger level for the BOD from 2.2V to 2.0V. Revision E – June 2008 • Removed Standard Packaging Offering. 45 3390E–MICRO–6/08

Headquarters International Atmel Corporation Atmel Asia Atmel Europe Atmel Japan 2325 Orchard Parkway Room 1219 Le Krebs 9F, Tonetsu Shinkawa Bldg. San Jose, CA 95131 Chinachem Golden Plaza 8, Rue Jean-Pierre Timbaud 1-24-8 Shinkawa USA 77 Mody Road Tsimshatsui BP 309 Chuo-ku, Tokyo 104-0033 Tel: 1(408) 441-0311 East Kowloon 78054 Saint-Quentin-en- Japan Fax: 1(408) 487-2600 Hong Kong Yvelines Cedex Tel: (81) 3-3523-3551 Tel: (852) 2721-9778 France Fax: (81) 3-3523-7581 Fax: (852) 2722-1369 Tel: (33) 1-30-60-70-00 Fax: (33) 1-30-60-71-11 Product Contact Web Site Technical Support Sales Contact www.atmel.com mcu@atmel.com www.atmel.com/contacts Literature Requests www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL’S TERMS AND CONDI- TIONS OF SALE LOCATED ON ATMEL’S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDEN- TAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel’s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. © 2008 Atmel Corporation. All rights reserved. Atmel®, logo and combinations thereof, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. 3390E–MICRO–6/08

Mouser Electronics Authorized Distributor Click to View Pricing, Inventory, Delivery & Lifecycle Information: M icrochip: AT89S2051-24PU AT89S2051-24SU AT89S4051-24PU AT89S4051-24SU