AT89S52 is one of the popular microcontrollers from the Atmel family. AT89S52 microcontroller is an 8-bit CMOS microcontroller having 8k Flash memory and 256 bytes of RAM memory. It can be operated at 33MHz maximum operating frequency by using an external oscillator. Like other microcontrollers, It has GPIO pins, three 16-bit timers, one full-duplex UART communication port, three 16-bit general-purpose timers, on-chip oscillator.
Furthermore, it has 40 pins, out of which 32 are GPIO pins. AT89S52 also has an inbuilt Watchdog timer to operate microcontroller low power mode. This microcontroller finds its applications from domestic devices to the industrial level to provide digital control to embedded systems.
AT89S52 Microcontroller Introduction
It is an 8-bit, low power, high performance, CMOS technology based microcontroller with having an operating frequency range between 0 to 33MHz. The chip can work in two power selectable operating modes. This device offers 32 GPIO pins which can be used as digital input-output pins or also same pins can be used for alternate functions.
The pinout of the AT89S52 8-bit microcontroller is shown below:
AT89S52 8-bit microcontroller is available in three packages. But the pinout diagram is the same for all three packages. The pin configuration detail in tabular is mentioned below:
|Pin Number||Pin Name||Function|
|32-39||Port 0||8 Address and Data/GPIO pins|
|1-8||Port 1||8 multi-purpose GPIO pins|
|21-28||Port 2||8 GPIO pins|
|10-17||Port 3||8 multi-purpose GPIO pins|
|9||RST||Master Reset pin|
|18||XTAL2||External Oscillator Output pin|
|19||XTAL1||External Oscillator Input pin|
|40||VCC||Power Supply pin|
|31||EA/VPP||External Access Enable/Flash Enable Supply pin|
|30||ALE/PROG||Address Latch Enable/Flash Program pin|
|29||PSEN||Program Store Enable pin|
Port 0 pins
All ports of AT89S52 are 8-bit which means each port has 8 multifunctional pins. These general-purpose input/output pins can be configured for other operations as well when configured for that purpose using alternate functions of configuration registers. If they are at a low state, they work as bidirectional high-impedance input pins. But if they pulled high, they are used as digital output pins.
Port0 pins are also used to upload lower bytes of code to the internal program memory of the AT89S52 microcontroller and also used for verification of uploaded code. While using these pins for programming, we need to connect external pull-up resistors with these pins.
Port 1 pins
Similar to port 0, Port1 also has 8-bit dual-directional pins with internal pull-up resistors. Some of these GPIO pins are used for in-circuit system programming interface and some are used as alternate functions for three 16-bit Timer/Counter pins.
Port 2 pins
Like port 1, Port2 also has 8-bit dual-directional pins with internal pull-up resistors. Some of these GPIO pins are used for in-circuit system programming interface and some are used as alternate functions for three 16-bit Timer/Counter pins.
Port2 pins are also used to upload higher bytes of code to the internal program memory of the AT89S52 microcontroller and also used for verification of uploaded code. While using these pins for programming, we need to connect external pull-up resistors with these pins.
Port 3 pins
Port 3 is also an 8-bit port and has 8 GPIO pins. In addition to the input/output function, these pins also have some special features. Port 3 also used for UART serial data transfer, external interrupts, and performs external data memory read/write operations.
All these pins are bi-directional and TTL pins. They can sink and source currents and all these have internal pull up resistors for properly defining their states.
AT89S52 Features and Specifications
|Features and Peripherals||Availability|
|Program Memory||8 KiloBytes|
|CPU speed||33 MHz|
|Number of Comparators||2|
|Number of Programmable I/O pins||32|
|Window Watchdog Timer||No|
|External Oscillator Frequency||23 MHz (max)|
|Resolution of PWM||No|
|Number of 16-bit Timers||3|
|Program Memory Type||Flash|
|Dual Data Pointer||Yes|
|Operating Voltage||4V – 5.5 V|
|Operating Temperature||-550C – 1250C|
Some of the eminent detailed features are listed below:
- It is a high-performance CMOS microcontrollers with Flash Technology
- The unit operates at a wide range of 4 – 5.5 volts, so it is a low power IC.
- The device supports In-system Programming both page and byte mode for the Flash memory.
- The operational frequency is up to 33MHz but can be altered for saving energy.
- The module has a quick programming time with 10,000 read/write cycles.
- The Random Access memory is organized in 256×8 bits.
- The serial communication takes place through a full duplex UART module.
- It comes with a reset option, three 16-bit timers and eight interrupts.
- AT89S52 has two power modes, i.e., idle mode in which stops processing unit stops while other peripheral keep working and power-down mode that halts oscillator and other functions and save RAM contents.
- Watchdog timer to work and wake the device up from sleep mode and can be activated or deactivated through programming
How to program AT89S52 8-bit Microcontroller
Different software and compilers available in the market can be used to program Atmel microcontrollers family.
We need an IDE, IPE, a suitable compiler, and a programmer/debugger to develop a program. The function of an IDE(Integrated Development Environment) is to provide the environment for programming. The compiler converts the program into readable HEX files. The IPE(Integrated Programming Environment) serves the purpose of burning HEX files in AVR MCUs.For IDE , we commonly use Keil uVision IDE.
USBASP is an In-circuit programmer/debugger which plays an integral role in programming microcontrollers. It supports In-Circuit-Serial-Programming and is operated by a computer to burn the code into AT89S52 8-bit microcontroller. For hardware programming, it is purchased separately. It is advised to simulate the program beforehand on the software for optimization and error free programs. Furthermore, hardware like 12 Volts adapter, 7805 Voltage Regulator, Crystal Oscillator and capacitors are required.
The picture below is the connection diagram for programming the AT89S52 controller:
- Sensor Systems
- Medical systems
- Home automation systems
- Low-cost embedded systems
- Defense and safety purposes
8051 Microcontroller Tutorials: