---
title: "8051 pin diagram; ports 1 and 2"
subject: "Embedded System"
chapter: 9
key: "semester_6/embedded_system:8051-pin-diagram-ports-1-2"
source: https://www.bctengineer.com/q/semester_6/embedded_system/8051-pin-diagram-ports-1-2
site: BCT Engineering
---

# 8051 pin diagram; ports 1 and 2

Embedded System · Chapter 9: Microcontrollers in Embedded Systems

- Asked in: 2072 Asoj, 3 marks
- Video: [8051 pin diagram | micro controller | | MPMC | Lec-55 | Bhanu Priya](https://www.youtube.com/watch?v=5fESTph5gA8) — Education 4u
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/embedded_system/8051-pin-diagram-ports-1-2
- Whole chapter: https://www.bctengineer.com/md/semester_6/embedded_system/chapter-9

## Question

Draw the pin diagram of 8051 microcontroller and explain ports 1 and 2 only.

## Short answer

Port 1 is an 8-bit bidirectional I/O port with internal pull-ups, always available for general I/O. Port 2 is also 8-bit bidirectional with pull-ups; it functions as I/O when no external memory is used, but outputs high address byte A8–A15 if external memory is attached.

## Answer

#### Pin diagram (40-pin DIP)

```text
              +-----\_/-----+
 P1.0       1 |             | 40  VCC
 P1.1       2 |             | 39  P0.0 AD0
 P1.2       3 |             | 38  P0.1 AD1
 P1.3       4 |             | 37  P0.2 AD2
 P1.4       5 |             | 36  P0.3 AD3
 P1.5       6 |             | 35  P0.4 AD4
 P1.6       7 |    8051     | 34  P0.5 AD5
 P1.7       8 |             | 33  P0.6 AD6
 RST        9 |             | 32  P0.7 AD7
 P3.0 RXD  10 |             | 31  EA/VPP
 P3.1 TXD  11 |             | 30  ALE/PROG
 P3.2 INT0 12 |             | 29  PSEN
 P3.3 INT1 13 |             | 28  P2.7 A15
 P3.4 T0   14 |             | 27  P2.6 A14
 P3.5 T1   15 |             | 26  P2.5 A13
 P3.6 WR   16 |             | 25  P2.4 A12
 P3.7 RD   17 |             | 24  P2.3 A11
 XTAL2     18 |             | 23  P2.2 A10
 XTAL1     19 |             | 22  P2.1 A9
 GND       20 |             | 21  P2.0 A8
              +-------------+
```

#### Port 1 (pins 1-8)

An 8-bit bidirectional I/O port with internal pull-ups. It has no alternate function in the basic 8051 (P1.0 and P1.1 are T2 and T2EX in the 8052), so it is always available for general I/O such as LEDs and switches. Writing 1 to a pin makes it an input.

#### Port 2 (pins 21-28)

An 8-bit bidirectional I/O port with internal pull-ups. It is used as plain I/O when no external memory is attached; with external memory it outputs the high-order address byte A8-A15 and then cannot be used for I/O.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which pins of the 40-pin 8051 form Port 1, and what is it used for?
   A. Pins 21-28, address lines
   B. Pins 10-17, special functions
   C. Pins 1-8, general-purpose I/O
   D. Pins 32-39, multiplexed address/data
   Answer: C. Port 1 is pins 1-8 and has no alternate function in the basic 8051, so it is always free for I/O. (Key point: Port 1 pins)

2. What does Port 2 do when external memory is attached?
   A. Outputs the low-order address byte A0-A7
   B. Outputs the high-order address byte A8-A15 and cannot be used for I/O
   C. Carries the data bus D0-D7
   D. Works as serial port
   Answer: B. With external memory Port 2 supplies A8-A15, so it is no longer available for ordinary I/O. (Key point: Port 2 dual role)

3. Which pins supply power to the 40-pin 8051?
   A. VCC at pin 40 and GND at pin 20
   B. VCC at pin 20 and GND at pin 40
   C. VCC at pin 1 and GND at pin 21
   D. VCC at pin 31 and GND at pin 9
   Answer: A. VCC is pin 40 and GND is pin 20. (Key point: Power pins)

4. How is a Port 1 pin made an input?
   A. By writing 0 to it
   B. By clearing the PSW
   C. By writing 1 to it
   D. By pulling EA low
   Answer: C. Port pins have internal pull-ups; writing 1 lets an external device drive the pin as an input. (Key point: Input configuration)

## Related in Embedded System

- [Microcontroller vs microprocessor; 8051 features](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Amicro-vs-microprocessor-8051-features) — Embedded System, chapter 9, asked 2×
- [Microprocessor vs microcontroller; 8051 addressing](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-addressing-modes-micro-vs-processor) — Embedded System, chapter 9
- [8051 minimum circuit and 75% duty pulse](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-min-config-pwm-75) — Embedded System, chapter 9
- [Addressing modes of 8051](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-addressing-modes) — Embedded System, chapter 9, asked 4×
- [Why 8051 / its operational features](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Awhy-8051-features) — Embedded System, chapter 9, asked 2×
- [Purpose of port 3 and port 2 of 8051](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-port3-port2-purpose) — Embedded System, chapter 9, asked 2×

## Related in other subjects

- [Equivalent Y-parameter of parallel two-ports](https://www.bctengineer.com/question.md?key=semester_3%2Felectrical_circuit_theory%3Aequivalent-y-parameter-parallel-two-ports) — Electrical Circuit Theory, chapter 7, asked 3×
- [Equivalent Z-parameter of three series two-ports](https://www.bctengineer.com/question.md?key=semester_3%2Felectrical_circuit_theory%3Aequivalent-z-parameter-three-series-two) — Electrical Circuit Theory, chapter 7, asked 3×
