what is an 8051 microcontroller?
As discussed in our earlier post on the Architecture of the 8501 microcontroller, The 8051 microcontroller is a popular and versatile 8-bit microcontroller based on Harvard architecture, used in a wide range of embedded systems. Developed by Intel, it features a simple architecture, 4KB of on-chip ROM, 128 bytes of RAM, CPU, and a variety of I/O ports.
The main purpose of the pin diagram is to interface with external devices such as sensors, actuators, displays, etc. It helps us to know the location of these pins and their functionalities. We can also customize the microcontroller as per our needs and keep only those pins that we need.
The 8051 microcontroller consists of 40 pins which are dedicated to various functions such as I/O, RD, WR, address, data, and interrupts. Out of which 32 pins are dedicated to Input output ports and the rest pins are for other purposes such as VCC, XTAL1, XTAL2, RST, ALE, EA’ and PSEN’, GND.
Pin diagram of 8051 microcontroller
The pin description of the 8051 microcontrollers is as follows:

- Port 1 (Pin 1-8): Port 1 is an 8-bit bidirectional I/O port. The Port-1 pins are internally pulled high with a fixed pull-up register. It has to be configured as input or output and writing a ‘1’ to the port latch causes it to act as input.
- Pin (9) Reset: RST pin 8051 is made high for two machine cycles for resetting the device while the oscillator is running. It initializes the ALE and PSEN signal in input modes. After resetting all port pins act like output pins by default.
- Port 3 ( Pins 10-17): Port 3 is an 8-bit bidirectional port. Each line can be used as a special function line specified by the contents of special function registers.
P3.0 | RXD serial input |
P3-1 | TXD serial input |
P3-2 | INT0 external interrupt |
P3-3 | INT1 external interrupt |
P3-4 | T0 timer/counter0 external input |
P3-5 | T1 timer/counter1 external write |
P3-6 | WR external data memory write |
P3-7 | RD external data memory read |
- XTAL 2 (Pin 18): Output of inverting amplifier that forms the part of the oscillator and input to the internal clock generator. In the case of the external clock, it should be connected to XTAL 2.
- XTAL 1 (Pin 19): XTAL 1 is the input to the inverting amplifier that forms the port of the oscillator circuit. In the case of an external clock, it is connected to the ground.
- GND (Pin 20): It provides ground to IC.
- Port 2 (Pin 21-28): It is an 8-bit bidirectional I/O, It functions as a high-order address bus during external access.
- PSEN (Pin 29): It is used to read the contents of external program memory. The program store enables (PSEN) as the output control signal activated every six oscillator periods while fetching the external program memory. It remains high during the internal program execution (data memory).
- ALE/PROG (Pin 30): Address latch enable(ALE) output is used for latching the low address byte during external memory access for providing properly, the ALE is activated twice every machine cycle.
- ALE=0, Port 0 operated as a Data line.
- ALE=1, Port 0 operates as an Address line
- EA/VPP (Pin 31): The external access (EA), when held high, executes an instruction from internal program memory till address OFFFH. If this pin is low, all instructions are fetched from external memory.
- EA=0, 8051 microcontrollers can access 64Kbytes of external memory.
- EA=1, 8051 microcontrollers can access 4Kbytes of internal memory and 60Kbyte of external memory.
- Port 0 (Pins 32-39): Port 0 is an 8-bit bidirectional open drain Input/Output, lower order address, and data bus is multiplexed with port 0. Port 0 is an open drain and must be pulled high externally through the pull-up resistor.
- VCC (Port 40): It is a supply pin of 8051 and requires a +5V DC supply.
Also, read