Embedded

8051 Pin Diagram

By CourseTron Team ·  8 min read ·  Updated Oct 2026 💬 𝕏 in f
Table of Contents
    ? Print / Save as PDF

    In short: The 8051 ships in a 40-pin DIP whose pins split into four 8-bit I/O ports (P0–P3), two power pins, a crystal oscillator pair (XTAL1/XTAL2), a reset input, and the memory-control quartet EA, PSEN, ALE and RST that together let one chip drive both on-chip and external memory.

    Few packages in embedded history are as instructive to decode pin-by-pin as the Intel 8031/8051. Even if you will spend your career inside an STM32 BGA or a RISC-V soft core, the 8051's 40-pin plastic DIP teaches the universal grammar of microcontroller pinouts: power, clock, reset, bidirectional ports, and the handful of control strobes that orchestrate a multiplexed address/data bus. This walkthrough labels every pin group and, more importantly, explains why each signal exists.

    The package at a glance

    The classic 8051 (and its EPROM sibling the 8751, ROM-less 8031, and the countless Atmel AT89C51/AT89S52 derivatives) comes in a 40-pin Dual In-line Package, 0.6 inch wide, pins on a 0.1 inch pitch. Pin 1 sits at the notch, numbering runs counter-clockwise. The symmetry is deliberate: ports occupy whole sides so PCB routing stays clean.

    8051 40-pin DIP pinout 8051 40-pin DIP P1.0 (1) VCC +5V (40) P1.7 (8) P0.0 AD0 (39) RST (9) P0.7 AD7 (32) P3.0 RxD (10) EA / VPP (31) P3.7 RD (17) ALE (30) XTAL2 (18) PSEN (29) XTAL1 (19) P2.7 A15 (28) VSS / GND (20) P2.0 A8 (21) CourseTron · coursetron.com
    Labeled 40-pin DIP map. Left side carries Port 1, reset and the oscillator; right side carries Port 0, control strobes and Port 2.

    Power, ground and the oscillator

    Pin 40 is VCC (+5 V nominal for the original NMOS part; CMOS derivatives like the AT89S52 run 4.0–5.5 V) and pin 20 is VSS (ground). A 100 nF decoupling capacitor between them, placed millimetres from the pins, is non-negotiable for stable operation.

    Pins 19 (XTAL1) and 18 (XTAL2) connect to the on-chip inverting amplifier that forms a Pierce oscillator. A typical 11.0592 MHz crystal with two 30 pF load capacitors to ground is standard — that odd frequency divides cleanly to generate exact UART baud rates like 9600. The 8051 divides the crystal by 12 internally, so 11.0592 MHz yields a 921.6 kHz machine cycle.

    Key fact: One 8051 machine cycle = 12 oscillator periods. At 12 MHz that is exactly 1 µs, which is why 12 MHz was the textbook default for timing calculations.

    Reset — pin 9 (RST)

    RST is active-high. Holding it high for at least two machine cycles forces the program counter to 0x0000 and clears most SFRs. The canonical circuit is a 10 µF capacitor from VCC to RST and a 10 kΩ resistor from RST to ground — an RC that keeps RST high long enough after power-up for the oscillator to stabilise, then decays to logic low for normal running.

    The four I/O ports

    Thirty-two of the forty pins form four byte-wide bidirectional ports. They are not identical, and the differences matter in every real design.

    PortPinsInternal pull-up?Alternate function
    P032–39No (open-drain)Multiplexed low address + data bus (AD0–AD7) for external memory
    P11–8YesPlain I/O (P1.0/P1.1 are timer-2 pins on the 8052)
    P221–28YesHigh address byte (A8–A15) for external memory
    P310–17YesRxD, TxD, INT0, INT1, T0, T1, WR, RD

    Port 0 is the exception that trips up beginners: its outputs are open-drain, so to use it as general-purpose I/O you must add external pull-up resistors (typically 10 kΩ). Intel made it open-drain because P0 doubles as the data bus — a floating high-impedance state is exactly what a shared bus needs.

    Port 3 carries the most overloaded pins. P3.0/P3.1 are the serial RxD/TxD; P3.2/P3.3 are external interrupts INT0/INT1; P3.4/P3.5 are timer inputs T0/T1; and P3.6/P3.7 are the WR and RD strobes for external data memory (MOVX instructions). Any P3 pin not used for its alternate role is a normal I/O line.

    Port 3 alternate functions (pins 10-17) P3.0RxDpin 10 · serial P3.1TxDpin 11 · serial P3.2INT0pin 12 · interrupt P3.3INT1pin 13 · interrupt P3.4T0pin 14 · timer input P3.5T1pin 15 · timer input P3.6WRpin 16 · MOVX strobe P3.7RDpin 17 · MOVX strobe CourseTron · coursetron.com
    Port 3 pin map: serial RxD/TxD, external interrupts INT0/INT1, timer inputs T0/T1 and the WR/RD data-memory strobes.

    The control quartet: EA, PSEN and ALE

    These three signals, plus RST, are what make the 8051 a genuine von-Neumann-flavoured controller able to extend itself with external chips.

    • EA (pin 31, External Access): Tie high to run code from internal ROM; tie low to force all code fetches from external program memory. On the ROM-less 8031 it is permanently grounded. On EPROM 8751 parts this pin doubles as VPP (the 12.75 V programming voltage).
    • PSEN (pin 29, Program Store Enable): The read strobe for external program memory. It pulses low twice per machine cycle during an external opcode fetch. It stays inactive when code runs from internal ROM.
    • ALE (pin 30, Address Latch Enable): Because P0 time-shares address and data, ALE pulses high to tell an external latch (a 74HC373) to capture the low address byte before P0 switches to carrying data. ALE also free-runs at 1/6 the oscillator frequency, handy as a clock source for peripherals.
    ALE latches the address off P0 ALEP0 (AD0-7)Latch out ADDR (low) DATA previous ADDR held stable by 74HC373 Falling edge of ALE captures the address (time moves right) CourseTron · coursetron.com
    Animated: ALE's falling edge latches the address off P0, so when P0 flips to carrying data the external latch still presents a stable address to memory.

    Key fact: Without ALE and the external latch, you would need 16 dedicated address pins plus 8 data pins — the multiplexed bus saves 8 package pins, the whole reason the 8051 fits in 40.

    How the pins work together in a real design

    Picture an 8031 (no internal ROM) booting from an external 27C256 EPROM. On reset, EA is grounded. The CPU drives an address, ALE latches P0's low byte into a 74HC373, P2 supplies the high byte, PSEN strobes low, and the EPROM returns the opcode on P0. For data (a MOVX to external RAM), P3.6 (WR) or P3.7 (RD) take over instead of PSEN. Modern logic analysers from Keysight or Saleae make these overlapping strobes visible in nanoseconds — a great way to internalise the timing. If you are designing custom silicon rather than wiring discretes, equivalent bus-handshake logic gets synthesised and verified in flows from Synopsys Design Compiler, Cadence Genus, or checked with Siemens Questa, but the pin-level contract is the same idea the 8051 made famous.

    For the register-transfer view of how these pins feed the CPU core, timers and SFRs, read our companion piece on the 8051 microcontroller architecture, and for the serial side see 8051 UART serial communication. Hands-on labs that wire every one of these pins live inside the CourseTron embedded systems courses. If you later move from firmware into chip design, the same von-Neumann bus intuition carries straight into the ASIC flows taught at ChipXpert's VLSI training.

    Want to flash your first HEX file onto a real 8051 and probe ALE on a scope? The CourseTron Embedded Systems with 8051 & ARM course walks you from pinout to bootloader with graded lab kits.

    Frequently asked questions

    Why does Port 0 need external pull-up resistors?

    P0's output drivers are open-drain, lacking the internal FET pull-up that P1, P2 and P3 have. This is intentional so P0 can float during its data-bus role. Used as plain I/O, each line needs a ~10 kΩ resistor to VCC to pull it high.

    What is the difference between PSEN and RD?

    PSEN (pin 29) reads external program/code memory during instruction fetch. RD (P3.7) reads external data memory during MOVX instructions. Keeping code and data strobes separate lets the 8051 address up to 64 KB of each independently.

    Can I leave the EA pin floating?

    No. EA must be tied high (internal ROM) or low (external only). A floating EA produces unpredictable fetch behaviour. On ROM-less 8031/8032 parts, wire it permanently to ground.

    Why is 11.0592 MHz so common instead of a round number?

    It divides down to produce exact standard UART baud rates (4800, 9600, 19200) with zero error, avoiding the framing problems a round 12 MHz crystal causes at higher baud rates.

    Advertisement