8051 is a single chip microcontroller designed by Intel in 1980 for use in embedded systems. Here single chip refers to all the components including processor, RAM, ROM, Input Output ports and Timers are all embedded on a single Integrated Circuit. It’s an 8-bit microcontroller means CPU can only work on 8-bit data at a time.

CPU: It’s the Brain of 8051 microcontroller. It does various arithmetic and logical calculations based on the Program it read from its memory.

Basic Block Diagram of 8051

ROM: It’s a memory in which program is saved. It’s non-volatile memory i.e. its data is not lost when power is turned off.

RAM: It’s also a memory used by microcontroller to save temporary data. It’s a volatile memory i.e. its data is lost when power is turned off.

Timer: It’s a peripheral of microcontroller which is used for timing calculations it can be programmed.

Input-Outputs ports: There are four input output ports in 8051 microcontroller which are used to interact with real world.

Serial Com Port: It’s a communication port which can be used to communicate with other microcontroller and even our personal computers and laptops.

Program: It’s a set of Instruction which is burnt on the ROM i.e. its Memory. Usually programming is done in ‘C’-Language which is converted into instructions which can be read by CPU of microcontroller i.e. hex code by a compiler.

 8051 Microcontroller Architecture

Architecture of a 8051 Microcontroller

The 8051 microcontroller architecture diagram is shown in above image. It is based on Harvard architecture means its CODE memory and DATA memory are physically separate memory areas. It’s an 8-bit microcontroller i.e. it has 8 bit Arithmetic and logic unit. All of its registers are of 8 bits except Program counter and DPTR. 

  • It has 8 bits of:
    • Data Bus
    • General Purpose Registers (R0-R7)
    • Program status Word (PSW)
    • stack pointer
    • Special function Registers (Accumulator, Register B)

Note: PSW and stack pointer are also SFR.

  • It has 16 bits of
    • Program counter (PC)
    • Data pointer (DPTR) 
  • It has on chip ROM of 4KB (0000H – 0FFFH).
  • RAM – 128 Bytes.
  • SFR Memory – 128 Bytes.
  • 32 I/O pins arranged as four 8-bit ports (P0 -P3)  
  • Two 16-bit timer/counters: T0 andT1
  • Full duplex UART (serial port)   
  • Interrupt controller Controlling 6 interrupts:
    • Reset 
    • External Hardware Interrupt 0(INT0)
    • Timer 0 Interrupt (TF0)
    • External Hardware Interrupt 1(INT1)
    • Timer 0 Interrupt (TF1)
    • Serial COM Interrupt (RI and TI)
  • Data Bus: It has 8 bits of data bus hence 8 bits of data can be transferred at a time
  • Address Bus: It has 16 bits of data bus hence it can address up to 64KB of Memory. It can be calculated as there are 16 bits which can either store ‘1’ or ‘0’. Hence total number of combinations are 2 ^ 16 = 65536. And one location can store one byte of data hence 65536 x 1 Byte = 64 x 1024 x 1 Byte = 64 Kilo byte = 64KB.  
Memory structure of 8051 microcontroller

8051 Microcontroller Features

  • It has 8-bit Central processing unit means CPU can only work on 8-bit data at a time.
  • It has 4 Kilo Bytes of programmable space referred to as Read Only Memory (ROM).
  • It has 128 Bytes of Random-Access Memory, its used for temporary saving of Data.
  • Two independent timers, which can be programmed as timers as well as counters.
  • 32 Input output pins which are divided into 4 ports which when act as an output control the external circuit by changing signals both to 5V or 0V and as an input read the input signals within its input range.
  • 6 interrupt sources i.e. there are 6 ways to directly interrupt the CPU. When interrupt is occurred then CPU stops running its current code jumps to a special routine executes its code and then restarts its normal running code. All this functioning is controlled by an interrupt controller.  
  • One serial port which can be used to communicate with other microcontroller and even our personal computers and laptops.
  • Address bus is 16-bit unidirectional.
  • Data bus is 8-bit bidirectional.
  • It has a 16-bit program counter and data pointer.

8051 Microcontroller Pin Diagram

Pin diagram of 8051 Microcontroller

8051 microcontrollers have four 8-bit I/O ports P0, P1, P2 and P3

Each uses 8 pins:

  • All the ports upon RESET are configured as input.
  • When the first 0 is written to a port, it becomes an output port.   
  • To reconfigure it again as an input, a 1 must be sent to that port. 
  • To use any of these ports as an input/output port, it must be programmed.

External configuration before using Port 0

It can be used for input or output; each pin must be externally connected to a 10K pull-up resistor, because P0 is an open drain, unlike P1, P2, and P3 Open drain is a term used for MOS chips in the same way that open collector is used for TTL chips.

8051 Hardware connection Circuit

Special functions of Port 3

Port 3 has the additional function of providing some important signals. To use them these pins must be explicitly configured before using them. It is shown in pin diagram of 8051. Each of them will be discussed in later sections.

Dual Role of port 0 and Port 2

  • Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data.
  • Port 2 is also designated as A8 – A15, indicating its dual function.
  • When connecting an 8051/31 to an external memory, port 0 provides both address and data.
  • Also, port 2 must be used along with P0 to provide the 16-bit address for an external memory.
  • Port 0 provides the lower 8 bits via A0 – A7.

8051 Hardware Connections

  • The 8051 has an on-chip oscillator but requires an external clock to run it. 
  • Hence a quartz crystal oscillator is connected to inputs XTAL1 (pin19) and XTAL2 (pin18). 
  • This oscillator is also connected to two capacitors of 30 pF value each.
  • Typically, 11.0592 MHz is the frequency of crystal oscillator which is can be connected to a typical 8051.
  • The value of crystal oscillator depends upon the maximum frequency an 8051 chip can handle e.g. a 12-MHz chip must be connected to a crystal with 12 MHz frequency or less.
  • RESET pin 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.
  • Above configuration in “8051 hardware connection diagram” is often referred to as a power-on reset.
  • Activating a power-on reset will cause all values in the registers to be lost.
  • In order for the RESET input to be effective, it must have a minimum duration of 2 machine cycles.
  • In other words, the high pulse must be high for a minimum of 2 machine cycles before it is allowed to go low.
  • EA, “External Access’’, is an input pin and must be connected to Vcc or GND.
  • In 8051 family members all come with on-chip ROM to store programs. Hence-EA pin is connected to Vcc. 
  • But in 8031 and 8032 family members do not have on-chip ROM, thus code is stored on an external ROM and is fetched by 8031/32.Hence EA pin must be connected to GND to indicate that the code is stored externally.
  • PSEN, “Program Store Enable’’, is an output pin. It is connected to the OE pin of the External ROM.
  • ALE, “Address Latch Enable”, is an output pin and is active high.
  • 8031 devices multiplexes address and data through port 0 to save pins.
  • 8031 devices use ALE pin for demultiplexing the address and data by connecting it to the G pin of the 74LS373 chip.
  • ALE indicates if P0 has address or data. 
    • When ALE=0, it provides data D0-D7.
    • When ALE=1, it has address A0-A7

    8051 Microcontroller Applications

    8051 Microcontroller is used in many embedded systems and applications. Some of the applications of 8051 Microcontroller are given below:

    • Consumer Appliances 
    • Communication Systems 
    • Aeronautical and Space
    • Robotics
    • Automobiles 
    • Medical Equipment
    • Defense Systems
    • Light sensing and controlling device

    FAQ’S

    What is a 8051 microcontroller?

    The 8051 microcontroller is a popular and widely used 8-bit microcontroller. It is packed with 128Kb of RAM, 4Kb of ROM, 4 ports, 2 timers and 1 serial port all on a single chip.

    How many pins are there in 8051 microcontroller?

    8051 microcontroller has a 40-pin dual in-line package (DIP) configuration. This means it has 40 physical pins that can be connected to external components or devices.

    What are the ports 3 pins of 8051?

    Port 3 (P3) in the 8051 microcontroller consists of eight pins: P3.0 (RXD) and P3.1 (TXD) for serial communication, P3.2 (INT0) and P3.3 (INT1) for external interrupts, P3.4 (T0) and P3.5 (T1) for external timers/counters, and P3.6 (WR) and P3.7 (RD) for controlling external memory or peripherals. These pins serve various functions such as serial data transfer, interrupt handling, timer input, and interfacing with external devices, providing flexibility and expandability to the microcontroller system.