---
title: "Purpose of port 3 and port 2 of 8051"
subject: "Embedded System"
chapter: 9
key: "semester_6/embedded_system:8051-port3-port2-purpose"
source: https://www.bctengineer.com/q/semester_6/embedded_system/8051-port3-port2-purpose
site: BCT Engineering
---

# Purpose of port 3 and port 2 of 8051

Embedded System · Chapter 9: Microcontrollers in Embedded Systems

- Asked in: 2073 Magh, 4 marks; 2079 Jestha, 4 marks (asked 2 times)
- Video: [IO Ports of 8051 Microcontroller: Detailed Working and Configurations Explained | 8051](https://www.youtube.com/watch?v=m3riF4rY8Hg) — Engineering Funda
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/embedded_system/8051-port3-port2-purpose
- Whole chapter: https://www.bctengineer.com/md/semester_6/embedded_system/chapter-9

## Question

Describe the different purpose of port 3 and port 2 of 8051 microcontroller.

## Short answer

Port 2 supplies the high address byte (A8-A15) during external memory access; otherwise it is general-purpose I/O. Port 3’s alternate functions are serial (RxD, TxD), external interrupts (INT0, INT1), timer inputs (T0, T1), and external memory read/write strobes (RD, WR).

## Answer

#### Port 2 (P2.0-P2.7)

- An 8-bit bidirectional I/O port with internal pull-ups. Writing 1 makes a pin an input.
- **Alternate function:** when external program or data memory is used, Port 2 outputs the **high-order address byte A8-A15**. P0 gives the low byte A0-A7 (multiplexed with data). Then P2 cannot be used for ordinary I/O.
- With no external memory it is a general-purpose I/O port, e.g. for LEDs or an LCD.

#### Port 3 (P3.0-P3.7)

- An 8-bit bidirectional I/O port with internal pull-ups. Each pin has a special alternate function, used when the corresponding feature is enabled:

| Pin | Name | Function |
|---|---|---|
| P3.0 | RXD | Serial data input |
| P3.1 | TXD | Serial data output |
| P3.2 | INT0 | External interrupt 0 |
| P3.3 | INT1 | External interrupt 1 |
| P3.4 | T0 | Timer/counter 0 external input |
| P3.5 | T1 | Timer/counter 1 external input |
| P3.6 | WR | External data memory write strobe |
| P3.7 | RD | External data memory read strobe |

So P2 mainly supplies the upper address lines, and P3 provides the control and special signals (serial, interrupts, timer inputs and read/write strobes).

## Check yourself

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

1. What does Port 2 supply when external memory is used?
   A. Serial data
   B. The high-order address byte A8-A15
   C. The low address byte A0-A7
   D. Read/write strobes
   Answer: B. P2 gives A8-A15; P0 gives the multiplexed low address and data. (Key point: Port 2 alternate)

2. Which pins of Port 3 are the serial port lines?
   A. P3.2 and P3.3
   B. P3.6 and P3.7
   C. P3.0 (RXD) and P3.1 (TXD)
   D. P3.4 and P3.5
   Answer: C. P3.0 is RXD (input) and P3.1 is TXD (output). (Key point: Port 3 serial pins)

3. Which pins give the external data memory write and read strobes?
   A. P3.0 and P3.1
   B. P3.4 and P3.5
   C. P2.0 and P2.1
   D. P3.6 (WR) and P3.7 (RD)
   Answer: D. P3.6 is WR and P3.7 is RD. (Key point: Port 3 strobes)

4. Which pins are external interrupt inputs?
   A. P3.2 (INT0) and P3.3 (INT1)
   B. P3.4 and P3.5
   C. P3.0 and P3.1
   D. P2.0 and P2.1
   Answer: A. INT0 and INT1 are on P3.2 and P3.3; P3.4/P3.5 are timer inputs T0/T1. (Key point: Port 3 interrupts)

## Related in Embedded System

- [Port 3 of 8051](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-port3-explain) — Embedded System, chapter 9
- [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
- [Port-based and bus-based I/O](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Aport-based-vs-bus-based-io) — Embedded System, chapter 5, asked 2×
- [Read switches at port 1, show on port 2](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-switch-port1-led-port2) — Embedded System, chapter 9, asked 2×
- [Blink 8 LEDs at port 2](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-blink-leds-port2) — Embedded System, chapter 9, asked 2×
