8051 - Frequently asked interview questions and answer

What is an 8051 microcontroller?

The 8051 microcontroller is an 8-bit microcontroller that was originally introduced by Intel. It is widely used in various embedded systems due to its simplicity, low cost, and availability.

2. Write down the Key Features of 8051?
  • 40 Pin IC.
  • 128 bytes of RAM.
  • 4K ROM (On-chip and could be different for different versions).
  • Two 16-bit Timers/Counter (T0 and T1).
  • 32 Input/ Output pins.
  • 1 serial port.
  • 6 Interrupts (Including Reset).
3. Why is 8051 called an 8-bit microcontroller?

The Intel 8051 is an 8-bit microcontroller which means that most available operations are limited to 8 bits.

4. How many interrupt sources do the 8051 microcontrollers have?
  • Timer 0 Interrupt.
  • Timer 1 Interrupt.
  • External Interrupt 0 (INT0).
  • External Interrupt 1 (INT1).
  • Reset Interrupt.
5.Explain the different memory spaces in the 8051 microcontrollers.

The 8051 microcontroller has 3 memory spaces:

  • Program/Code memory (ROM): It stores the program code to be executed.
  • Data memory (RAM): It is used to store the data during program execution.
  • Special Function Register (SFR) memory: It consists of various control and data registers used to interface with peripherals.
6. What is the function of the SBUF register in the 8051 microcontrollers?

The SBUF (Serial Buffer) register is used to holds the data to be transmitted or received through the serial port for serial communication in the 8051 microcontroller.

7. What is the function of the EA (Enable All) pin in the 8051 microcontrollers?

The EA (Enable All) pin is used to enable or disable all interrupts in the 8051 microcontroller. When the EA pin is high (1), all interrupts are enabled, and when it is low (0), all interrupts are disabled.

8. Explain the function of the PSW register in the 8051 microcontrollers and its various flags.

The PSW (Program Status Word) register contains the status flags and the stack pointer. It includes the flags for carry bit (CY), auxiliary carry bit (AC), overflow bit (OV), parity bit (P), and user-defined flags (UD), Register Bank Select (RS0,RS1).

Carry Flag (CY): Its Indicates a carry or borrow after an arithmetic operation.

Auxiliary Carry (AC): Its Used for BCD (Binary Coded Decimal) arithmetic to detect carry from lower nibble to upper nibble.

Overflow Flag (OV): Signals when signed arithmetic operations result in overflow or underflow.

Parity Flag (P): Reflects even or odd parity of accumulator content, useful for error detection.

Register Bank Select bits (RS0, RS1): Determine which of the four available register banks (R0-R7) is currently active.

User-definable Flag (F0): Its Available for custom use by the programmer.

9. What interrupt latency? How can you reduce it?

The amount of time required to return from the interrupt service procedure after addressing a particular interrupt is known as interrupt latency. It is possible to decrease interrupt latency by making the small ISR functions.

10.How many instructions can be executed per second in 8051 frequency 12MHz?

A cycle is 12 pulses of the crystal. That is if an instruction takes one machine cycle to execute, it will take 12 pulses of the crystal to execute. Since we know the crystal is pulsing 11,059,000 times per second and that one machine cycle is 12 pulses, we can calculate how many instruction cycles the 8051 can execute per second.

11,059,000 / 12 = 921,583 This means that the 8051 can execute 921,583 single-cycle instructions per second.

11.What is the maximum amount of external RAM that can be interfaced with the 8051 microcontroller?

The 8051 microcontroller can interface a maximum of 64 KB of external RAM.

12.What is the size of the register bank in the 8051 microcontrollers?

The 8051 microcontroller has four register banks and each contains eight registers. Each register is 8 bits.

13.What is the function of the ALE pin in the 8051 microcontrollers?

The ALE (Address Latch Enable) pin is used to demultiplex the data and address bus during the external memory access. It indicates that the address is stable on the bus and the data can be read or written.

14.How can you enable and disable interrupts in the 8051 microcontroller?

Interrupts can be enabled or disabled by setting(1) or clearing(0) the particular bits in the Interrupt Enable (IE) register. By setting the corresponding bit, a specific interrupt source can be enabled, and by clearing the bit, it can be disabled.

15.How does the 8051 microcontroller handle I/O operations?

The 8051 microcontroller has four 8-bit I/O Ports (P0, P1, P2, and P3) that can be used for both input and output operations. These ports can be configured as either input or output by setting or clearing the corresponding bits. By configuring the bits setting (1) means as input or clearing the bits its mean as output (0).

For example : Suppose we have to make Port 2 as a O/P operation then you have to write like this → P2=0x00;

Now, Suppose we have to make Port 3 as a I/P operation then you have to write like this → P3=0xFF;

16. What Is The Difference Between Harvard Architecture And Von Neumann Architecture?

The Harvard Mark is the source of the name Harvard Architecture. Harvard Architecture's physical separation of buses and storage for code and data memory. Program memory and data memory can both be accessed simultaneously. Data memory is often read-write, but code (or program) memory is typically read-only.

John von Neumann, a mathematician and pioneer in the field of computing, is the name of the von Neumann architecture. Von Neumann machines communicate buses and have shared data and code memory. Since the program is kept in read-write memory, it may readily be changed by itself.

17. How do you configure the Timer/Counter unit of the 8051 Microcontroller for various operational modes? Provide examples.

To configure the Timer/Counter unit of the 8051 Microcontroller, follow these steps:

  1. Select the desired timer (Timer 0 or Timer 1) by accessing its control register (TMOD).
  2. Choose the operational mode (Mode 0-3) by setting appropriate bits in TMOD.
  3. Configure the timer as a timer or counter by setting or clearing the C/T bit in TMOD.
  4. Load the initial value into the timer's low and high bytes (TLx and THx).
  5. Enable the timer by setting the corresponding TRx bit in TCON.
  6. Monitor the overflow flag (TFx) to determine when the timer has reached its limit.
18. Describe the process of using interrupts in the 8051 Microcontroller. How can you enable, disable, and prioritize them?

Interrupts in the 8051 Microcontroller are used to handle events that require immediate attention, allowing the main program to continue executing. To use interrupts, follow these steps:

  1. Configure interrupt sources: Set up external or internal sources like timers, serial communication, or I/O pins.
  2. Enable specific interrupts: Use the IE (Interrupt Enable) register to enable desired interrupts by setting corresponding bits.
  3. Set priority levels: Assign priorities using IP (Interrupt Priority) register if multiple interrupts occur simultaneously.
  4. Write ISR (Interrupt Service Routine): Create a function to handle the interrupt and place it at the appropriate vector address.
  5. Enable global interrupts: Set EA (Enable All) bit in the IE register.
19. What methods can be used for analog-to-digital conversion using the 8051 Microcontroller.

The 8051 Microcontroller doesn't have an in-built ADC, so we have to connect the external ADC module/IC.

External ADC Interfacing: A mostly the ADC0804 chip is used to interface with 8051. Connect the analog input to its VIN+ pin, and digital output pins (D0-D7) to the 8051's port pins. Control signals like CS, RD, and WR are connected to other port pins. Start conversion by setting CS pin as low and when CS pin as High then the ADC conversion is Stop and WR low, then read data when INTR becomes low.