Understanding AT89S51 microcontroller and pin functions

Publisher:脑洞飞翔Latest update time:2016-01-21 Source: eefocusKeywords:AT89S51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    AT89S51 is a low voltage, high performance CMOS 8-bit microprocessor with 4K bytes of flash programmable and erasable read-only memory (FPEROM), commonly known as a single-chip microcomputer. The device is manufactured using ATMEL's high-density non-volatile memory manufacturing technology and is compatible with the industry-standard MCS-51 instruction set and output pins. As it combines a multifunctional 8-bit CPU and flash memory in a single chip, ATMELAT89S51 is an efficient microcontroller that provides a highly flexible and inexpensive solution for many embedded control systems.

    AT89S51 integrates all the functions of a computer into this chip. Such a small chip can constitute a small computer, so it is called a single-chip microcomputer.

 

    It has 40 pins, divided into two rows, each row has 20 pins, the one with an arrow in the lower left corner is the first pin, and then in a counterclockwise direction are the second pin, the third pin... the 40th pin.

 

   Among the 40 pins, 32 of them can be used for various controls, such as controlling the on and off of a small light, controlling the forward and reverse rotation of a motor, controlling the rise and fall of an elevator, etc. These 32 pins are called the "ports" of the microcontroller. In microcontroller technology, each port has a specific name, such as the port on the first pin is called "P1.0". Since this experiment only controls the on and off of a small light, only one port is needed. Let's use the P1.0 port on the first pin. 1. Main features:

·Compatible with MCS-51
·4K bytes of programmable flash memory
Lifespan: 1000 write/erase cycles
Data retention time: 10 years
·Fully static operation: 0Hz-24Hz
·Three-level program memory lock
·128*8-bit internal RAM
·32 programmable I/O lines
·Two 16-bit timers/counters
·5 interrupt sources
·Programmable serial channel
·Low-power idle and power-down modes
·On-chip oscillator and clock circuit

2. Pin description:

    VCC: power supply voltage.
    GND: ground.
    P0 port: P0 port is an 8-bit open-drain bidirectional I/O port, each pin can absorb 8TTL gate current. When the pin of P1 port is written as 1 for the first time, it is defined as high-impedance input. P0 can be used for external program data storage, and it can be defined as the eighth bit of data/address. When FLASH is programmed, P0 port is used as the original code input port. When FLASH is verified, P0 outputs the original code. At this time, P0 must be pulled high externally.
    P1 port: P1 port is an 8-bit bidirectional I/O port with an internal pull-up resistor. The buffer of P1 port can receive and output 4TTL gate current. After the pin of P1 port is written as 1, it is pulled up internally to high and can be used as input. When P1 port is pulled down externally to low level, it will output current. This is due to the internal pull-up. When FLASH is programmed and verified, P1 port is received as the eighth bit of address.
    P2 port: P2 port is an 8-bit bidirectional I/O port with an internal pull-up resistor. The P2 port buffer can receive and output 4 TTL gate currents. When the P2 port is written with "1", its pin is pulled high by the internal pull-up resistor and used as input. And therefore, when used as input, the pin of the P2 port is pulled low externally and outputs current. This is due to the internal pull-up. When the P2 port is used to access the external program memory or the 16-bit address external data memory, the P2 port outputs the upper eight bits of the address. When the address "1" is given, it takes advantage of the internal pull-up. When reading and writing the external eight-bit address data memory, the P2 port outputs the contents of its special function register. The P2 port receives the upper eight-bit address signal and control signal during FLASH programming and verification.
    P3 port: The P3 port pins are 8 bidirectional I/O ports with internal pull-up resistors, which can receive and output 4 TTL gate currents. When the P3 port is written with "1", they are internally pulled high and used as input. As input, due to the external pull-down to low level, P3 port will output current (ILL) This is due to the pull-up.

P3 port can also be used as some special function ports of AT89C51, as shown in the following table:
Port Pin Alternative Function
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)
P3.6 /WR (External Data Memory Write Strobe)
P3.7 /RD (External Data Memory Read Strobe)
P3 port also receives some control signals for flash programming and programming verification.

    RST: Reset input. When the oscillator resets the device, keep the RST pin high for two machine cycles.
ALE/PROG: When accessing external memory, the output level of the address latch enable is used to latch the address status byte. During FLASH programming, this pin is used to input programming pulses. Normally, the ALE terminal outputs a positive pulse signal with a constant frequency cycle, which is 1/6 of the oscillator frequency. Therefore, it can be used as a pulse for external output or for timing purposes. However, it should be noted that whenever it is used as an external data memory, an ALE pulse will be skipped. If you want to disable the output of ALE, you can set it to 0 at the SFR8EH address. At this time, ALE will only work when executing MOVX, MOVC instructions. In addition, the pin is slightly pulled high. If the microprocessor is in the external execution state, ALE is disabled, and the setting is invalid.

   /PSEN: The selection signal of the external program memory. During the instruction fetch from the external program memory, /PSEN is valid twice per machine cycle. However, when accessing the external data memory, these two valid /PSEN signals will not appear.
    /EA/VPP: When /EA is kept at a low level, the external program memory (0000H-FFFFH) is used during this period, regardless of whether there is an internal program memory. Note that when encryption mode 1 is used, /EA will be internally locked to RESET; when the /EA terminal is kept at a high level, the internal program memory is used during this period. During FLASH programming, this pin is also used to apply 12V programming power (VPP).
    XTAL1: Input of the reverse oscillator amplifier and input of the internal clock operating circuit.
    XTAL2: Output from the reverse oscillator.

3. Oscillator characteristics:

    XTAL1 and XTAL2 are the input and output of the reverse amplifier respectively. The reverse amplifier can be configured as an on-chip oscillator. Both crystal oscillation and ceramic oscillation can be used. If an external clock source is used to drive the device, XTAL2 should not be connected. The excess input to the internal clock signal must pass through a divide-by-two trigger, so there is no requirement for the pulse width of the external clock signal, but the width of the high and low levels of the pulse must be guaranteed.

4. Chip Erase:

    Electrical erasure of the entire PEROM array and three lock bits can be accomplished by the correct combination of control signals and keeping the ALE pin at a low level for 10ms. In the chip erase operation, the code array is written with "1" and this operation must be performed before any non-empty storage byte is reprogrammed.
In addition, the AT89S51 has steady-state logic, which can be static logic under low to zero frequency conditions, and supports two software-selectable power-down modes. In idle mode, the CPU stops working. However, the RAM, timer, counter, serial port and interrupt system are still working. In power-down mode, the contents of the RAM are saved and the oscillator is frozen, and all other chip functions are disabled until the next hardware reset.

   Many netizens who are new to 51 MCUs have this question: What is AT89S51? Books and online tutorials all mention 8051, 89C51, etc.! Have you ever heard of 89S51? !

    Here, beginners need to clarify a product concept in the actual use of MCUs. MCS-51 MCUs are products launched by INTE Corporation of the United States in 1980. Typical products include 8031 ​​(no internal program memory, which has been eliminated by the market in actual use), 8051 (the chip uses HMOS, the power consumption is 630mW, which is 5 times that of 89C51, which has been eliminated by the market in actual use) and 8751 and other general products. Until now, MCUs compatible with the MCS-51 core series are still the mainstream products used (such as the currently popular 89S51, the discontinued 89C51, etc.). The training materials of various universities and professional schools still use MCS-51 MCUs as representatives for theoretical basic learning.

    Some documents even refer to 8051 as the MCS-51 series of microcontrollers. 8051 is the most typical representative work in the early days. Due to the far-reaching influence of MCS-51 microcontrollers, many companies have launched compatible series of microcontrollers, which means that the MCS-51 core has actually become a standard for 8-bit microcontrollers.

    The 51 microcontroller products of other companies are all compatible with the MCS-51 core. The same program will have the same results when running on the hardware of various microcontroller manufacturers, such as ATMEL's 89C51 (discontinued), 89S51, PHILIPS, and WINBOND. The discontinued 89C51 we often refer to is ATMEL's AT89C51 microcontroller, which has enhanced many features on the original basis, such as the clock. What's more, the original ROM (one-time write) is taken from the Flash (the content of the program memory can be rewritten at least 1,000 times) memory. The performance of AT89C51 is already very superior to 8051.

    However, in terms of marketization, 89C51 has been challenged by the PIC microcontroller camp. The most fatal flaw of 89C51 is that it does not support the ISP (online update program) function. New functions such as ISP function must be added to better continue the legend of MCS-51. 89S51 replaced 89C51 in this context. Now, 89S51 has become the new darling in the actual application market. Atmel, which has the largest market share, has stopped producing AT89C51 and will replace it with AT89S51. 89S51 has been improved in process. 89S51 adopts 0.35 new process, which reduces cost and improves function, increasing competitiveness. 89SXX can be compatible with 89CXX and other 51 series chips. At the same time, Atmel no longer accepts orders for 89CXX. The 89C51 you see in the market is actually the huge inventory produced by Atmel in the early stage.

The new features added by 89S51 compared with 89C51 include:

-- Many new features have been added, the performance has been greatly improved, but the price remains basically the same, even lower than 89C51!

-- ISP online programming function. The advantage of this function is that the program in the microcontroller memory does not need to be removed from the working environment. It is a powerful and easy-to-use function.

-- The operating frequency is 33MHz. As we all know, the maximum operating frequency of 89C51 is only 24M, which means that S51 has a higher operating frequency and thus has a faster computing speed.

-- It has a duplex UART serial channel.

-- The internal integrated watchdog timer no longer needs an external watchdog timer unit circuit like 89C51.

-- Dual data indicators.

-- Power off mark.

-- A new encryption algorithm, which makes it impossible to decrypt 89S51, and the confidentiality of the program is greatly enhanced, so that intellectual property rights can be effectively protected from infringement.

-- Compatibility: Fully backward compatible with all 51-word series products. For example, 8051, 89C51 and other early MCS-51 compatible products. That is to say, all the programs in textbooks and online tutorials (regardless of whether the microcontroller used in the textbook is 8051, 89C51, MCS-51, etc.) can run normally on 89S51. This is the so-called backward compatibility.  

Keywords:AT89S51 Reference address:Understanding AT89S51 microcontroller and pin functions

Previous article:51 MCU C language learning notes 1: MCS-51 system structure
Next article:51 single chip microcomputer uses C language to realize accurate delay program

Recommended ReadingLatest update time:2024-11-16 13:30

Design of AT89S51 microcontroller and 82C55 interface chip
1.Hardware interface circuit The figure below shows the circuit diagram of AT89S51 microcontroller extended by an 82C55. In the figure, 74LS373 is the address latch. P0.1 and P0.0 are connected to the address lines A1 and A0 of 82C55 through 74LS373; P0.7 is connected to the chip select terminal CS through 74LS373, an
[Microcontroller]
Design of AT89S51 microcontroller and 82C55 interface chip
Design of PID Temperature Control System Based on AT89S51 Single Chip Microcomputer
  Temperature control technology not only plays a very important role in industrial production, but also plays a vital role in daily life. This paper designs the hardware and software of the system. On the basis of establishing the mathematical model of the temperature control system, the system controller is designed
[Microcontroller]
Design of PID Temperature Control System Based on AT89S51 Single Chip Microcomputer
System expansion structure based on AT89S51
  The AT89S51 microcontroller adopts a bus structure, which makes expansion easy to achieve. The AT89S51 microcontroller system expansion structure is shown in the figure below.      As can be seen from the above figure, system expansion mainly includes memory expansion and I/O interface component expansion. The exter
[Microcontroller]
System expansion structure based on AT89S51
Timing counter T0 is used as timing technology
1. Circuit diagram Figure 4.16.1 2. System board hardware connection (1. Connect P1.0-P1.3 in the "MCU System" area to L1-L4 in the "Eight-way LED Indicator Module" area with wires. 3. Programming content (1. Since the interrupt method is used, the interrupt source must have its interrupt entry address. F
[Microcontroller]
Timing counter T0 is used as timing technology
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号