AT89S52/ AT89C52 8-Bit Microcontroller
AT89S52/ AT89C52 8-Bit Microcontroller
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.
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)