Understanding the 8051 microcontroller architecture is essential for developing embedded systems. It lays the foundation for the development of efficient, low-power, and cost-effective microcontroller-based applications. Programmers may optimize code and exploit the full power of this widely used microcontroller by being familiar with its structure, instruction set, and peripherals.
The 8051 microcontroller is a popular and versatile 8-bit microcontroller based on Harvard architecture, used in a wide range of embedded systems. Developed by Intel, it features a simple architecture, 4KB of on-chip ROM, 128 bytes of RAM, CPU, and a variety of I/O ports.
8051 microcontroller architecture
The above figure shows the block diagram of the 8051 microcontroller. It has the following blocks.
- Central processing unit (CPU):- The 8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a time. CPU consists of ALU i.e. arithmetic and logic units. It performs arithmetic and logical operations on an 8-bit operand. The accumulator register gets the output from ALU in most arithmetic and logical operations. The ALU is associated with two registers, A and B, which are special function registers, which hold the result of arithmetic and logical operations.
- Interrupt Control:- Interrupt is a subroutine call that interrupts the microcontroller’s main operations or work and causes it to execute any other program that is more important at the time of operation. Generally, six interrupt sources are there in the 8051 microcontroller.
- RST- Reset
- INT0- External Interrupt 0
- TFO – Timer 0
- TF1 – Timer 1
- INT1- External Interrupt 1
- R1/T1 – Serial port interrupt
Out of these INT0 and INT1 are external interrupts that could be triggered at lower level. When all these interrupts are activated, Set the corresponding flags except for serial interrupt. The interrupt flags are cleared when processors branches to interrupt service routine (ISR).
- Memory in 8501 Microcontroller:- The 8051 microcontroller has on-chip 4K bytes of ROM (program memory) which can be extended up to 64K bytes using an EA pin. On-chip data memory is 256 bytes out of which 128 bytes is on-chip RAM. And 128 bytes are reserved for special function resistors (SFR).
- Timer control unit:- The 8051 has two 16-bit timer counters, which are programmable namely, timer 0 and timer 1. In the timer mode of operation, they can be independently programmed to work in any of the four operation modes, namely mode 0, mode 1, mode 2, and mode 3. In the counter mode of operation, they can count the number of high-to-low transitions of a signal applied to timer pins.
- Serial Port:- The 8051 contains UART i.e. universal asynchronous receiver and transmitter. It means the serial port of the 8051 microcontroller is a full duplex, and it can transmit and receive simultaneously. There are more serial port operations.
- Mode 0: Synchronous mode, Data transferred on RXD clock on TXD
- Mode 1: Asynchronous mode, 10-bit data frame ( start bit, 8 data bit, and stop bit)
- Mode 2: Asynchronous mode, 11-bit data frame (start bit, 8 data bit, programmable 9th bit and stop bit)
- Mode 3: Same as mode 2 but with programmable baud rate.
- I/O port: The 8051 microcontroller has four 8-bit bidirectional I/O ports, each consisting of a latch (special function resistors P0 to P-3) an output driver, and an input buffer. The output drivers of Port 0 and Port 2 and the input buffer of Port 0 are used to access external memory. Port 3 pins are multifunctional pins. Port one is the only port that has no special function. It acts as only a bidirectional input-output port
- Bus Control:- The system bus consists of an 8-bit data bus, a 16-bit address bus, and bus control signals. All the devices like program memory, port, data memory, serial interface, interrupt control, timer, and the CPU are all interfaced together through the system bus. The address bus is generally used for transferring data from CPU to memory, Whereas the Databus is used for transferring the data from one peripheral position to the other peripherals.
- Oscillator: The 8051 Microcontroller uses an external crystal oscillator that operates at 12 MHz frequency. The Oscillator drives the internal clock generator. The clock generator provides the internal clocking signals to the chip. The internal clocking signals are at half the oscillator frequency.