You are on page 1of 12

AT89S52/ AT89C52 8-bit Microcontroller

AT89S52 8-bit Microcontroller AT89S52 Microcontroller Pinout

Brief Intro to AT89S52 Microcontroller


The AT89S52 comes from the popular 8051 family of Atmel Microcontrollers. It is an 8-
bit CMOS microcontroller with 8K as Flash memory and 256 bytes of RAM. Since it is
similar to the trust worthy 8051 architecture these microcontrollers are as per industry
standard. It has 32 I/O pins comprising of three 16-bit timers, external interrupts, full-
duplex serial port, on-chip oscillator and clock circuitry.
The device is manufactured using Atmel’s high density non – volatile memory
technology and is compatible with the industry-standard 80C51 instruction set and
pinout. The on-chip Flash allows the program memory to be reprogrammed in-system
or by a conventional non – volatile memory programmer. By combining a versatile 8-bit
CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a
powerful microcontroller which provides a highly flexible and cost-effective solution to
many embedded control applications.
The Microcontroller also has Operating mode, Idle Mode and Power down mode which
makes it suitable for battery operated applications. Few considerable drawback of the
microcontroller is that it does not have in-built ADC and does not support SPI or I2C
protocols. However you we utilize external modules for the same.

AT89S52 Pin Configuration

Pin Number Pin Name Description


1 P1.0 (T2) Timer/Counter or 0th GPIO pin of PORT 1
2 P1.1 (T2.EX) Timer/Counter/External Counter or 1st GPIO pin of PORT 1
3 P1.2 2nd GPIO pin of PORT 1
4 P1.3 3rd GPIO pin of PORT 1
5 P1.4 4th GPIO pin of PORT 1
6 P1.5 (MOSI) MOSI for in System Programming or 5th GPIO pin of PORT 1
7 P1.6 (MISO) MISO for in System Programming or 6th GPIO pin of PORT 1
8 P1.7 (SCK) SCK for in System Programming or 7th GPIO pin of PORT 1
9 RST Making this pin high will reset the Microcontroller
10 P3.0 (RXD) RXD Serial Input or 0th GPIO pin of PORT 3
11 P3.1 (TXD) TXD Serial Output or 1st GPIO pin of PORT 3
12 P3.2 (INT0’) External Interrupt 0 or 2nd GPIO pin of PORT 3
13 P3.3 (INT1’) External Interrupt 1 or 3rd GPIO pin of PORT 3
14 P3.4 (T0) Timer 0 or 4th GPIO pin of PORT 3
15 P3.5 (T1) Timer 1 or 5th GPIO pin of PORT 3
16 P3.6 (WR’) Memory Write or 6th GPIO pin of PORT 3
17 P3.7 (RD’) Memory Read or 7th GPIO pin of PORT 3
18 XTAL2 External Oscillator Output
19 XTAL1 External Oscillator Input
20 GND Ground pin of MCU
21 P2.0(A8) 0th GPIO pin of PORT 2
22 P2.1 (A9) 1st GPIO pin of PORT 2
23 P2.2 (A10) 2nd GPIO pin of PORT 2
24 P2.3 (A11) 3rd GPIO pin of PORT 2
25 P2.4 (A12) 4th GPIO pin of PORT 2
26 P2.5 (A13) 5th GPIO pin of PORT 2
27 P2.6 (A14) 6th GPIO pin of PORT 2
28 P2.7 (A15) 7th GPIO pin of PORT 2
29 PSEN’ Program store Enable used to read external program memory
30 ALE / PROG’ Address Latch Enable / Program Pulse Input
31 EA’ / VPP External Access Enable / Programming enable Voltage
32 P0.7 (AD7) Address / Data pin 7 or 7th GPIO pin of PORT 0
33 P0.6 (AD6) Address / Data pin 6 or 6th GPIO pin of PORT 0
34 P0.5 (AD5) Address / Data pin 5 or 5th GPIO pin of PORT 0
35 P0.4 (AD4) Address / Data pin 4 or 4th GPIO pin of PORT 0
36 P0.3 (AD3) Address / Data pin 3 or 3rd GPIO pin of PORT 0
37 P0.2 (AD2) Address / Data pin 2 or 2nd GPIO pin of PORT 0
38 P0.1 (AD1) Address / Data pin 1 or 1st GPIO pin of PORT 0
39 P0.0 (AD0) Address / Data pin 0 or 0th GPIO pin of PORT 0
40 VCC Positive pin of MCU (+5V)
 

Port 0:
Port 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 high
impedance inputs. Port 0 may 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 (IIL) 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.

Port 3:
Port 3 pin details
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 also
serves the functions of various special features of the AT89S52 as listed in Table below .
XTAL1: Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2: Output from the inverting oscillator amplifier.

AT89S52 Microcontroller Features


AT89S52 –Simplified Features
CPU 8-bit PIC
Number of  Pins 40
Operating Voltage (V) 4 to 5.5 V
Number of Programmable I/O pins 32
ADC Module Nil
Timer Module 16-bit(1)
Comparators Nil
DAC Module Nil
Communication Peripherals UART(1)
External Oscillator Up to 23Mhz
Internal Oscillator Nil
Program Memory Type Flash
Program Memory (KB) 8KB
CPU Speed (MIPS) -
RAM Bytes 256 x 8-bit
Data EEPROM Nil
 
Programming AT89S52 Microcontroller
Atmel microcontroller can be programmed with different software's that is available in
the market. Arduino, Keil uVision are the most used platforms to name a few. If you are
planning on serious programming and expansion with community support then Keil is
recommended.
In order to program the Atmel microcontroller we will need an IDE (Integrated
Development Environment), where the programming takes place. A compiler, where our
program gets converted into MCU readable form called HEX files. An IPE (Integrated
Programming Environment), which is used to dump our hex file into our MCUs.
IDE: Keil uVision IDE
Programming Hardware: USB In-circuit programmer (USBASP)
Programmer: USBASP
To dump or upload our code into Atmel IC we need a programmer, the most commonly
used programmer is the USBASP which has to be purchased separately. Also simulating
you program on software before trying it on hardware will save a lot of time. So you can
use software like ISIS proteus from Labcenter to simulate you r programs.
A bare minimum circuit to program an Atmel microcontroller is shown below.
The mother board of AT89S52 has following sections:

Power Supply, AT89S52 IC, Oscillator, Reset Switch and I/O ports. Let us see these sections in
detail.

1) POWER SUPPLY

This section provides the clean and harmonic free power to IC to function properly. The
output of the full wave rectifier section, which is built using two rectifier diodes, is given to filter
capacitor. The electrolytic capacitor C1 filters the pulsating dc into pure dc and given to Vin pin-
1 of regulator IC 7805.This three terminal IC regulates the rectified pulsating dc to constant +5
volts. C2 & C3 provides ground path to harmonic signals present in the inputted voltage. The
Vout pin-3 gives constant, regulated and spikes free +5 volts to the mother board. The
allocation of the pins of the AT89S52 follows a U-shape distribution. The top left hand corner is
Pin 1 and down to bottom left hand corner is Pin 20. And the bottom right hand corner is Pin 21
and up to the top right hand corner is Pin 40. The Supply Voltage pin VCC is 40 and ground pin
VSS is 20.
2) OSCILLATOR

If the CPU is the brain of the system then the oscillator, or clock, is the heartbeat. It provides
the critical timing functions for the rest of the chip. The greatest timing accuracy is achieved
with a crystal or ceramic resonator. For crystals of 2.0 to 12.0 MHz, the recommended capacitor
values should be in the range of 15 to 33pF. Across the oscillator input pins 18 & 19 a crystal x1
of 4.7 MHz to 20 MHz value can be connected. The two ceramic disc type capacitors of value
30pF are connected across crystal and ground, stabilizes the oscillation frequency generated by
crystal.

3) I/O PORTS

There are a total of 32 I/O pins available on this chip. The amazing part about these ports is
that they can be programmed to be either input or output ports, even "on the fly" during
operation! Each pin can source 20 mA (max) so it can directly drive an LED. They can also sink a
maximum of 25 mA current.

Some pins for these I/O ports are multiplexed with an alternate function for the peripheral
features on the device. In general, when a peripheral is enabled, that pin may not be used as a
general purpose I/O pin. The alternate function of each pin is not discussed here, as port
accessing circuit takes care of that. This 89C51 IC has four I/O ports and is discussed in detail:
P0.0 TO P0.7 PORT0 is an 8-bit [pins 32 to 39] open drain bi-directional I/O port. As an output
port, each pin can sink eight TTL inputs and configured to be multiplexed low order
address/data bus then has internal pull ups. External pull ups are required during program
verification.

P1.0 TO P1.7

PORT1 is an 8-bit wide [pins 1 to 8], bi-directional port with internal pull ups. P1.0 and P1.1 can
be configured to be the timer/counter 2 external count input and the timer/counter 2 trigger
input respectively.

P2.0 TO P2.7

PORT2 is an 8-bit wide [pins 21 to 28], bi-directional port with internal pull ups. The PORT2
output buffers can sink/source four TTL inputs. It receives the high-order address bits and some
control signals during Flash programming and verification.

P3.0 TO P3.7

PORT3 is an 8-bit wide [pins 10 to 17], bi-directional port with internal pull ups. The Port3
output buffers can sink/source four TTL inputs. It also receives some control signals for Flash
programming and verification.

4) PSEN TDS
Program Store Enable [Pin 29] is the read strobe to external program memory.
5) ALE
Address Latch Enable [Pin 30] is an output pulse for latching the low byte of the address
during accesses to external memory.
6) EA

External Access Enable [Pin 31] must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H upto FFFFH.

7) RST

Reset input [Pin 9] must be made high for two machine cycles to resets the device’s oscillator.
The potential difference is created using 10MFD/63V electrolytic capacitor and 20KOhm resistor
with a reset switch.

 
Detailed Features
AT89S52 – Detailed Features
CPU 8-bit 8051 family
Architecture 8
Program Memory Size (Kbytes) 8K Flash
RAM (bytes) 256
EEPROM/HEF Nil
Pin Count 40
Max. CPU Speed (MHz) 33
Peripheral Pin select (PPS) No
Internal Oscillator No
No. Of comparators 2
No. Of  Operational Amplifier 0
No. Of ADC channels Nil
Max ADC Resolution (bits) NA
ADC with Computation No
Number of DAC Converter 0
Max DAC resolution 0
Internal Voltage Reference NA
Zero Cross Detect No
No. Of 8-bit timers 0
No. Of 16-bit Timers 3
Signal Measurement Timer 0
Hardware Limit Timer 0
No. Of PWM outputs 0
Max PWM resolution NA
Angular Timer No
Math Accelerator No
No. Of  UART module 1
No. Of SPI Module 0
No. Of I2C module 0
No. Of USB Module 0
Windowed Watchdog Timer (WWDT) No
CRC/Scan No
Numerically Controlled Oscillator 0
Cap. Touch Channels NA
Segment LCD 0
Minimum Operating Temperature (*C) -55
Maximum Operating Temperature (*C) 125
Minimum Operating Voltage (V) 4
Maximum Operating Voltage (V) 5.5
High Voltage Capable No
 
How to select your Atmel Microcontroller
Microchip provides a vast variety of Microcontrollers from PIC family and Atmel Family.
Their collection has just piled up after Microchip has acquired Atmel. Each MCU has its
own advantage and disadvantage. There are many parameters that one has to consider
before selecting a MCU for his/her project. The below points are just suggestions which
might help one to select a MCU.

 If you are a beginner who is learning Microcontroller then, selecting a MCU that has
good online community support and wide applications will be a good choice. For Atmel
AT89S52 or ATmega328 will be a good choice.
 Consider the operating voltage of your system. If they are 5V then select a 5V MCU some
sensors or devices work and communicate on 3.3V in such case a 3.3V MCU can be
selected
 If size and price is a limitation then you can choose small 8-pin MCUs like Attiny1614.
These are also comparatively cheaper.
 Based on the sensors and actuators used in your project, verify which modules you might
need in for MCU. For example is you are reading many Analog voltages then make sure
MCU has enough ADC channels and supportive resolution. The details of all modules are
given in the table above.
 If you project involves communication protocols like UART, SPI ,I2C, CAN etc make sure
you MCU can support them. Some MCU can support more than one module of the same
protocol

 
Applications
 Multiple DIY Projects
 Very good choice if you are learning ATmel
 Projects requiring Multiple I/O interfaces and communications
 Replacement for Arduino Module
 Ideal for more advanced level A/D applications in automotive, industrial, appliances and
consumer applications.
2D Model (PSDIP)

You might also like