Pin Description of 8051

Updated on 2017/08/19 18:46

Pin Description of 8051

Pin Description of 8051

8051 microcontroller families (89C51, 8751, DS89C4xO, 89C52) come in different packages like quad-flat package, leadless chip carrier and dual-in-line package. These all packages consist of 40 pins which are dedicated to several functions such as I/O, address, RD, WR, data and interrupts. But, some companies offer a 20-pin version of the microcontrollers for less demanding applications by reducing the number of I/O ports. Nevertheless, a vast majority of developers use the 40-pin chip.
The pin diagram of 8051 microcontroller consists of 40 pins as shown below. A total of 32 pins are set away into four Ports such as P0, P1, P2 and P3. Where, each port contains 8 pins. Therefore, the microcontroller 8051’s pin diagram and explanation is given below.

8051-pin-diagram.png
Fig. Pin Diagram of 8051 Microcontroller

  • There are four ports P0, P1, P2, and P3.
  • Each port uses 8 pins.
  • All I/O pins are bi-directional.
  • The four I/O ports:
    • Port 0 (Pins 32-39): P0(P0.0~P0.7)
    • Port 1 (Pins 1-8): P1(P1.0~P1.7)
    • Port 2 (Pins 21-28): P2(P2.0~P2.7)
    • Port 3 (pins 10-17): P3(P3.0~P3.7)
  • Each port has 8 pins.
  • Named P0.X, P1.X, P2.X, P3.X; where (X=0,1,...,7)
    • Ex: P0.0 is the bit 0 (LSB) of P0
    • Ex: P0.7 is the bit 7 (MSB) of P0
  • These 8 bits form a byte.
  • Each port can be used as input or output (bi-direction)

Port 0 (Pin 32 to 39)

Similar to the port 2 and 3 pins, these pins can be used as input output pins when we don’t use any external memory. When ALE or Pin 30 is at 1, then this port is used as data bus: when the ALE pin is at 0, then this port is used as a lower order address bus (A0 to A7)

Pin NoPort PinDescription
32P0.7Normal Input or Output pin OR Address Bus line 7(A7) Line or Data Bus line 7(D7)
33P0.6Normal Input or Output pin OR Address Bus line 6(A6) Line or Data Bus line 6(D6)
34P0.5Normal Input or Output pin OR Address Bus line 5(A5) Line or Data Bus line 5(D5)
35P0.4Normal Input or Output pin OR Address Bus line 4(A4) Line or Data Bus line 4(D4)
36P0.3Normal Input or Output pin OR Address Bus line 3(A3) Line or Data Bus line 3(D3)
37P0.2Normal Input or Output pin OR Address Bus line 2(A2) Line or Data Bus line 2(D2)
38P0.1Normal Input or Output pin OR Address Bus line 1(A1) Line or Data Bus line 1(D1)
39P0.0Normal Input or Output pin OR Address Bus line 0(A0) Line or Data Bus line 0(D0)

Port1 (Pin1 to Pin8):

Port1 includes pin1.0 to pin1.7 and these pins can be configured as  input or  output pins.

Pin NoPort PinDescription
1P1.0Normal Input or Output pin 
2P1.1Normal Input or Output pin 
3P1.2Normal Input or Output pin 
4P1.3Normal Input or Output pin 
5P1.4Normal Input or Output pin 
6P1.5Normal Input or Output pin 
7P1.6Normal Input or Output pin 
8P1.7Normal Input or Output pin 

Pin 9 (RST): Reset pin is used to Reset 8051 Microcontroller by giving a positive pulse to this Pin.Pin 9 is the RESET pin. It is an input and is active high (normally low). Upon applying a high pulse to this pin, the microcontroller will reset and terminate all activities. This is often referred to as a power-on reset. Activating a power-on reset will cause all values in the registers to be lost. It will set program counter to all Os.

Port3 (Pin 10 to 17):

The Port3 Pins are similar to port1 pins and can be used as universal Input or output pins. These pins dual-function Pins and the function of each Pin is given as:

Pin NoPort PinDescription
10P3.0(RXD): RXD pin is a Serial Asynchronous Communication Input or Serial synchronous Communication Output.
11P3.1(TXD): Serial Asynchronous Communication Output or Serial Synchronous Communication clock Output.
12P3.2(INT0): Input of Interrupt 0
13P3.3(INT1): Input of Interrupt 1
14P3.4(T0): Input of Counter 0 clock
15P3.5(T1): Input of Counter 1 clock
16P3.6(WR): Writing Signal to write content on external RAM.
17P3.7(RD): Reading Signal to read contents of external RAM.

Pin 18 and 19 (XTAL2, XTAL1): X2 and X1 pins are input output pins for the oscillator. These pins are used to connect an internal oscillator to the microcontroller. The 8051 has an on-chip oscillator but requires an external clock to run it. Most often a quartz crystal oscillator is connected to inputs XTAL1 (pin 19) and XTAL2 (pin 18). The quartz crystal oscillator connected to XTAL1 and XTAL2 also needs two capacitors of 30 pF value. One side of each capacitor is connected to the ground as shown in Figure 8-2 (a).

Pin 20 (GND): Pin 20 is a ground pin.

Port2 (Pin 21 to Pin28):

Port2 includes pin21 to pin28 which can be configured as Input Output Pins. But, this is only possible  when we don’t use any external memory. If we use external memory, then these pins will work as high order address bus (A8 to A15).

Pin NoPort PinDescription
21P2.0Normal Input or Output pin OR Address Bus line 0(A0) Line
22P2.1Normal Input or Output pin OR Address Bus line 1(A1) Line 
23P2.2Normal Input or Output pin OR Address Bus line 2(A2) Line 
24P2.3Normal Input or Output pin OR Address Bus line 3(A3) Line 
25P2.4Normal Input or Output pin OR Address Bus line 4(A4) Line 
26P2.5Normal Input or Output pin OR Address Bus line 5(A5) Line 
27P2.6Normal Input or Output pin OR Address Bus line 6(A6) Line 
28P2.7Normal Input or Output pin OR Address Bus line 7(A7) Line 

Pin 29 (PSEN):This is an output pin. PSEN stands for “program store enable.” In an 8031-based system in which an external ROM holds the program code, this pin is connected to the OE pin of the ROM.

Pin 30 (ALE): ALE (address latch enable) is an output pin and is active high. When connecting an 8031 to external memory, port 0 provides both address and data. In other words, the 8031 multiplexes address and data through port 0 to save pins. The ALE pin is used for demultiplexing the address and data by connecting to the G pin of the 74LS373 chip.

Pin 31 (EA):The 8051 family members, such as the 8751/52, 89C51/52, or DS89C4xO, all come with on-chip ROM to store programs. In such cases, the EA pin is connected to Vcc. For family members such as the 8031 and 8032 in which there is no on-chip ROM. code is stored on an external ROM and is fetched by the 8031/32. Therefore, for the 8031 the EA pin must be connected to GND to indicate that the code is stored externally. EA. which stands for “external access,” is pin number 31 in the DIP packages. It is an input pin and must be connected to either Vcc or GND. In other words, it cannot be left unconnected.

Pin40 (VCC): This VCC pin is used for power supply.

References

  • WikiNote Foundation
Tags:
Created by Sujit Wagh on 2017/08/19 18:44