Skip to main content

8051 pin diagram; ports 1 and 2

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.

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

Pin diagram (40-pin DIP)

              +-----\_/-----+
 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.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Embedded System chapter 9 questions →