Interview Level 8051 MCU

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

About the Indian Institute of Embedded Systems:

Indian Institute of Embedded Systems is ISO 9001:2015 certified ED-Tech company


providing on-site &online education for Engineering Graduates, Colleges/Universities,
Corporates & Defence.

IIES expertise is in leading technologies like Embedded (Microcontrollers & Microprocessors, ),


Electric Vehicle (EV), VLSIetc…

We also specialize in Firmware building languages like C, C++, DS, Embedded C,MATLAB, &
PYTHON etc..

Specialists at IIES possess more than 15 years of experience, we provide training solutions in
various engineering disciplines mainly Electrical, Electronics, Wireless, Communication, Signal
Processing & Computer science.

Our Placement Oriented Courses:

• PG Diploma in Embedded Systems Design and Development – 6 Months


• PG Diploma in Internet of Things – 6 Months
• PG Diploma in Data science with AI and ML– 6 Months

Document Contents:

8051 Microcontroller 50 Q&A

www.iies.in [email protected] +919886920008


1) Define microcontroller?

A microcontroller is a potent computer that is more compact than conventional computers while
still providing many of the same functions. On a single chip, it often houses a processor, memory,
and peripherals like input/output pins. It can also operate basic electronic devices like automated
doors, remote-control cars, toys, and appliances.

The software code used to programme microcontrollers is application-specific and provides


instructions for the controller to carry out tasks independently. For instance, using a Smartphone
to manage home appliances or detecting temperature under specific circumstances.
Microcontrollers are smaller and consume less power than conventional computers, making them
perfect for today's mobile and portable devices that cannot accommodate larger processors.

2) What kinds of things may a microcontroller be used for?

This is one among the often requested questions in freshmen's microcontroller interview questions.
Microcontrollers, or MCUs, can be used in everything from tiny machines to robust machinery.
Basic robotics, gaming systems, digital audio and video equipment, industrial automation
equipment and control systems, sensors in home appliances, vehicle control systems like anti-lock
brakes and airbags, power management systems like switching power supplies and motor
controllers, high-speed bus architectures used in computers of all sizes from desktops to embedded
microprocessors, and many other types of communication devices are common applications for
microcontrollers.

They are also present in consumer goods like GPS systems, digital cameras, and cell phones. In
conclusion, microcontrollers are crucial parts that are widely used.

3) What distinguishes microcontrollers from microprocessors?

Although microprocessors and microcontrollers may carry out similar tasks, they differ in a few
key ways. The central processing unit (CPU) is the only component of a microprocessor, which is
the primary distinction between the two. A microcontroller, on the other hand, has the CPU,

www.iies.in [email protected] +919886920008


memory, and input/output modules all built into a single chip. Each device has a specific
application because of the differences in their structures.

In general, personal computers benefit the most from microprocessors, whereas embedded systems
benefit the most from microcontrollers. Although there is some overlap in their operations, these
fundamental differences should be considered if you're wanting to do specific tasks in order to
better understand which sort of processor is ultimately more suitable for your particular needs.

4) What technology was used in the development of the 8051?

The MCS-51 family from Intel was initially created using NMOS technology, but later iterations,
denoted by a letter C in their designation (such as the 80C51), employed CMOS technology and
used less power than their NMOS forebears. They become more appropriate for battery-powered
devices as a result.

5) Why is the 8051 referred to as an 8-bit microcontroller?

The majority of possible operations on the Intel 8051 are 8-bit operations just because it is an 8-
bit microcontroller.

6) What are the characteristics of 8051 microcontrollers?

Listed below the 8051 microcontroller fundamental features

➢ 40 Pin IC.
➢ RAM with 128 bytes.
➢ 4K ROM (On-chip and may vary depending on version).
➢ Timer 0 and Timer 1 are two timers.
➢ pins with 32 input/outputs.
➢ One serial port.
➢ (Including reset) 6 interruptions.

7) Where does the boundary between code memory and data memory start?

www.iies.in [email protected] +919886920008


For internal or external memory, at position 0x00

8) How much RAM is available on the chip?

Internal RAM on the original Intel 8051 Microcontroller ranged from 0x00 to 0x7F in size.
However, the RAM on practically all contemporary 8051 Microcontroller variations is 256B (0x00
to 0xFF).

9) How many instructions (of 1 machine cycle and 2 machine cycles) can be executed in a
second with a clock frequency of 12 MHz?

In actuality, a cycle consists of 12 crystal pulses. In other words, if an instruction takes one machine
cycle to complete, it will also complete in 12 crystal pulses. Since one machine cycle is made up
of 12 pulses and the crystal pulses 11,059,000 times each second, we can determine how many
instruction cycles the 8051 can carry out in a second.

11,059,000 / 12 = 921,583

This means that the 8051 can execute 921,583 single-cycle instructions per second. Since a large
number of 8051 instructions are single-cycle instructions it is often considered that the 8051 can
execute roughly 1 million instructions per second, although, in reality, it is less–and, depending on
the instructions being used, an estimate of about 600,000 instructions per second is more realistic.

10) What does.lst stands for?


➢ A list file is another name for this particular file.
➢ It lists the addresses, opcodes, and faults that the assembler found.
➢ The list file is only created when the user specifies it.
➢ An editor can access it and view it on a computer screen or print it off.
➢ This file is used by the programmer to identify syntax mistakes, which are then corrected.

11) Define DB?

In the assembler, DB is known as define byte and is used as a command.

www.iies.in [email protected] +919886920008


The 8-bit data can be defined in binary, hexadecimal, or decimal formats.

The only directive that allows for the definition of ASCII strings with more than two characters is
this one.

Memory is also allocated in byte-sized blocks using DB.

The numbers are always changed into hexadecimal by the assembler.

12) Describe EQU.

The assembler directive EQU is used to define constants without taking up memory space.

It links the data label to a constant value.

The constant value is used in place of the label each time it appears in the programme.

Advantage: By utilizing this directive, it is possible to update many constant values that appear
across a programme at once.

13) In assembly language, how are labels named?

A label may be positioned at the start of a sentence. The label serves as an instruction operand and
receives the current value of the active location counter during assembly. Before utilizing the
labels, you should be aware of the rules.

Label names must be original and include upper- and lowercase letters from the alphabet.

➢ An alphabetic letter should always be the first letter.


➢ Additionally, it supports numerals and special characters like.,@,_,$.
➢ Assembly language's reserved terms shouldn't include the label.
➢ The programme is much simpler to read and maintain thanks to these labels.

www.iies.in [email protected] +919886920008


14) Are all of the flag register's bits utilised in the 8051?

Status bits in the Programme Status Word (PSW) reflect the CPU's current state. This status
information is provided by the 8051 versions in a single, unique function register called PSW.
The programme status word (PSW) register, also referred to as the flag register, is an 8-bit
register. It is 8 bits wide, although only 6 bits of it are really used. User-defined flags are stored
in the two unused bits. Four of the flags are referred to be conditional flags since they show a
state that develops after an instruction is carried out. These four are OV (overflow), P (parity),
CY (carry), and AC (auxiliary carry). The bank registers are modified by the bits RS0 and RS1.
The following graphic displays the program status word register.

15) What problems exist with stack and bank 1?

The stack and Bank 1 share the same amount of RAM.

The push or pop instruction determines whether to increase or decrease the stack pointer.

Locations 7, 6, 5, and so on, which are part of register bank 0, are used when the stack pointer is
decremented.

The stack is allocated new memory space if a given programme uses R1.

www.iies.in [email protected] +919886920008


The stack may potentially be taken to location 0 by the push command, meaning it will run out of
room.

16) Can an 8051 access a single bit of a port?

In response, we can. Suppose we type the instruction SETB P1.2, for instance. It indicates that we
are setting port 1's second pin, which I'm referring to because pins start at zero.

17) What is the 8051 microcontroller's timer and counter for?

Timers and counters can be used to measure durations, produce delays, count events, and produce
baud rates for serial transmission. The timers and counters on the 8051 microcontroller are
controlled and configured by a number of particular registers, including TCON, TMOD, TL0,
TH0, TL1, TH1, and others.

The timers can be used to create delays or intervals of time in timer mode, and they can count
events or pulses in counter mode. The CPU can read from and write to the timer and counter values,
and these values can be used to drive a variety of microcontroller actions.

18) Registers in a microcontroller: what are they?

Using microcontrollers and processors, register offers a quick way to gather and store data. In
order to conduct operations like addition, subtraction, and other data manipulation activities with
a controller or processor, we need registers to process and store the data. We cannot perform these
operations directly in memory. According to their contents or the instructions that use them, the
various register types found in microcontrollers can be categorized.

There are essentially two categories of registers in the 8051 microcontroller:

➢ Byte addressable registers (general purpose registers)


➢ Bit addressable registers with special functions

The 256 bytes of RAM memory in the 8051 microcontroller are split into two groups: 128 bytes
for general-purpose use and 128 bytes for special function registers (SFR) memory. The memory
used for SFR contains all the peripheral-related registers, including the Accumulator, "B" register,

www.iies.in [email protected] +919886920008


Timers or Counters, and interrupt-related registers. The memory used for general purposes is
referred to as RAM memory.

19) List of the interrupts that the 8051 microcontroller supports


➢ The top priority interrupt is external interrupt 0 (IE0).
➢ (TF0) Timer interrupt 0
➢ Timer interrupt 1 (TF1) has the lowest priority of all the interrupts, followed by External
interrupt 1 (IE1).
➢ Serial port interrupt
➢ Reset

20) What does a microcontroller interrupt service routine do?

A microcontroller will invoke an ISR (Interrupt service routine) when a sudden interrupt
occurs. This routine stores the address of the current memory address and takes control of the
new interrupt memory address. Following the interruption, control will return to its original
address.

21) What is the 8051 microcontroller's architecture?

The Harvard Architecture-based 8051 Microcontroller was created primarily for use in
embedded systems technologies. Its structure is composed of the following units.

Memory BUS Oscillator Input/output Port Timers/Counters are interrupted by the central
processing unit (CPU).

22) What do the address, data, and control buses in the microprocessor 8051 do?

Bus Address: The address bus is used to transfer addresses from the CPU to the microcontroller's
memory and to address memory locations. The data is transferred using a 16 bit address bus on the
microcontroller 8051.There are four addressing modes for the 8051.

Modes for immediate addressing or a bank address Addressing register mode.

www.iies.in [email protected] +919886920008


Mode of direct addressing

The indirect addressing mode registers

Data Bus: Data Bus is used to transfer data between the memory and the input and output devices
of the microprocessor. As a microprocessor needs to send and receive data, it is bi-directional.
When multiplexed with a lower order address bus, the data bus can likewise serve as an address
bus. The data bus on the 8051 contains 8 bits and is used to carry data for specific purposes.

Control Bus: The control bus controls the flow of information between components, signaling
whether an operation is a read or a write and making sure that it occurs at the appropriate moment.

23) What does an 8051 microcontroller data pointer do?

One of the storage registers of 8051 microcontrollers is called the data pointer. The
accumulator, the stack pointer (SP), the R register, the B register, and the programme counter
(PC) are additional storage registers in an 8051 microprocessor. The only 2-byte register that
a user can access in 8051 microcontrollers is the Data Pointer, abbreviated DPTR. The B
register and accumulator are two other 1-byte registers. Just as its name suggests, this data
pointer is used for data pointing. The 8051 may access memory from outside the system using
it.

24) Describe the relationship between the external EPROM device and the microprocessor.

In many device designs, microcontroller interfaces with external memory components are
essential since they are frequently employed in embedded systems. An EEPROM (electrically
erasable programmable read-only memory) module, which offers non-volatile stored data or
instructions, is one such component that can be interfaced with microcontrollers.

25) Why are flags and registers used for serial communication in microcontrollers?

SCON, SBUF, TI, and RI are used in serial communication. The microcontroller's Tx and Rx
pins can send and receive data because serial communication is made possible by the USART
Control and Status Register B (UCSRB) register.

www.iies.in [email protected] +919886920008


While the TXEN bit enables data transmission, the RXEN bit will allow data receipt.

26) Can the 8051 be interfaced with all of the external data memory?

The 8051 microcontroller is a single-chip, inexpensive microprocessor that can be utilised in


a variety of embedded systems and applications. Due to its versatility and ease of use, it is also
among the most widely used microcontrollers ever. This chip's memory capacity, which
includes internal and external RAM, is an essential feature.

Internal and external RAM are both available for the 8051 microprocessor. Only 128 bytes
(256 bytes if you have an 8052) of internal RAM are available on 8051 microcontrollers. Any
data kept in internal RAM must so fit within these constraints. 64K (64 kilobytes) is the
maximum amount of external RAM that may be linked to an 8051 microprocessor. This means
that a second device can interface with the 8051 and hold up to 64K worth of data, such as
programme code or variables. Large amounts of data that would not fit in the limited internal
RAM capacity can also be stored in external RAM.

27) What does the 8051 microcontroller's stack pointer do?

An 8051 microcontroller's stack pointer (SP) keeps track of the current location of the stack,
which is utilised as scratch memory. Depending on the characteristic of different versions of
the 8051, SP, which points to the last utilised address, is either decremented or increased by 1
when data is pushed onto the stack.

The directive PUSH increases SP by 1 in addition to saving the contents of the register(s) onto
the stack. The stack pointer of the 8051 is crucial in providing effective means of regulating
programme flow and simplifying conversion between data kinds.

28) In the microprocessor 8051, what's the difference between a bit addressable and a byte
address?

Bit-addressable and byte-addressable differ primarily in the manner in which they make data
accessible. Since data can be retrieved one byte at a time using byte addressable technology, all 8
bits can be acquired or altered simultaneously.

www.iies.in [email protected] +919886920008


Contrarily, bit addressable technology enables the independent acquisition or modification of
individual bits. When only particular fields within a given set of binary data need to be read or
altered, this might be extremely helpful. This might occur, for instance, when programming a
microcontroller like the 8051.

29) What distinguishes timers and counters in a microcontroller?

This common set of fundamental interview questions for microcontrollers should be expected.
Microcontrollers use two different sorts of peripheral devices: counters and timers. A timer keeps
track of the passing of time and measures it with the intention of imposing a delay or waiting
period before sending a signal again. The frequency of an internal system clock is typically used
to compute this delay.

On the other hand, counters count signals from external sources like motors or encoders to
determine the frequency of pulses. They typically use pulse width modulation, detecting the width
of the incoming external pulses, and then producing a control signal based on these measurements.
Timer and counter devices combined offer unique capabilities that can be tuned to assist in various
applications within a microcontroller.

30) How are I/O devices for embedded systems categorized?

Character-mode or block-mode devices are the two main categories of I/O devices. Character-
mode devices make it possible for the system to communicate unstructured data, where each byte
is sent and received separately.

On the other hand, block-mode devices are made to convey huge amounts of data in a single
operation, typically in the form of fixed-length blocks or frames. This makes data transfer more
effective but is only practical if the data files are prepared in advance and organized. In addition,
depending on the OS vendors, block mode transfers generally demand for a unique protocol
interface.

31) When output overflows to the sign bit, which bit of the flag register is set?

www.iies.in [email protected] +919886920008


The second bit of the flag register is set when output flows to the sign bit. This flag is also
known as the overflow flag. The output of the signed number procedure in this situation is too
large to fit within 7 bits. For signed numbers, the MSB is used to indicate whether the number
is positive or negative. It is only used to detect errors in signed number operations.

32) A simple microcontroller programme that blinks an LED every 10 seconds should be
written.

The LED connected to pin RC1 of PORTC will illuminate after a 1-second delay (1 s=1000 ms).

TRISC of Instruction 2 configures PORTC as an output port. Pin 1 of the PORTC is set to 1
(HIGH) in instruction 4, then after a delay of 1000ms, it is set to 0 (LOW) in instruction 6. This
procedure is repeated until the programme is terminated.

33) What sets microcontroller assembly-level programming apart from C programming?

To answer this topic, one can talk about the advantages and disadvantages of each choice as well
as how a microcontroller C programme can also call an assembly line of codes. The sole benefit
of assembly language is smaller, faster code, but memory is now cheap; a microcontroller with 16
KB of programme memory costs just slightly more than one with 8 KB; and C compilers have
gotten better at producing smaller code, even if free ones aren't as good.

34) Which two ports combine to create the 16-bit address needed to access external memory?
➢ Together, ports 0 and 2 make up the 16-bit address for external memory.
➢ The 8051's pins 32 to 39 are used by Port 0 to provide the lower address bits (AD0-AD7).
➢ The 8051's pins 21 to 28 are used by port 2 to transmit the higher address bits (A8-A15).
➢ If there is an attachment, this 16-bit address is utilised to access external memory.
➢ They cannot be utilised as input or output ports when linked to external memory.

35) Write the Addresses That Can Be Addressed By Bits.

The 8051's bit addressable memory is made up of 210 bits: bit address space: SFR registers, 20H
- 2FH bytes RAM = 00H - 7FH bits address.

www.iies.in [email protected] +919886920008


36) Is Port 0 Capable of Input and Output?

You can use port 0 as an input or output port, yes. Contrary to ports 2, 3, and 4, port 0 is an open
drain. The 10k ohm pull-up resisters are externally linked to it in order to use it as an input or
output. Port 0 must be programmed by writing 1 to every bit in order to make it an input port.

37) What Is The Data Bus Width?


Data bus in 8 bits

38) What Is The Address Bus Width?


Sixteen-bit address bus

39) Where Do Data Memory Space And Code Memory Space Start?
For internal or external memory, at position 0x00

40) Special Function Registers (SFR): What Are They?


SFR refers to the memory locations in the range of 80H to 0FFH. These 128-byte registers
were created with interrupts and a few additional actions in mind.

41) Explain Program status word register


Register for the PSW (programme status word) The register for the programme status word
(PSW) has 8 bits. The flag register is another name for it. The PSW register is 8 bits wide,
however the 8051 only uses 6 of those bits. User-definable flags are the two unused bits. Four
of the flags are referred to be conditional flags since they show some conditions that might
arise after an instruction is carried out. These four are OV (overflow), P (parity), CY (carry),
and AC (auxiliary carry).
The bank registers are modified using the bits PSW.3 and PSW.4, which are referred to as
RSO and RSI, respectively. In the part after, they are described. The PSW.5 and PSW.l bits
are all-purpose status flags that the programmer is free to utilise whenever they see fit. They
can be defined by the user, in other words.

www.iies.in [email protected] +919886920008


The four flag bits of the PSW register are briefly explained in the sections that follow. It
is then discussed how instructions affect these registers.
The carry flag, CY
Every time there is a carry out from the D7 bit, this flag is set. Following an addition or
removal of 8 bits, this flag bit is impacted. By using an instruction like "SETB C" and "CLR
C," which stand for "set bit carry" and "clear carry," respectively, it is also possible to set it
straight to 1 or 0, respectively.
Auxiliary carry flag AC
This bit is set during an ADD or SUB operation if there is a carry from D3 to D4, otherwise
it is cleared. Instructions that carry out BCD (binary coded decimal) arithmetic use this flag.
More details can be found in Chapter 6.
The parity flag, P
Only the number of 1 seconds in the A (accumulator) register are reflected in the parity flag.
P = 1 if there are an odd number of Is in the A register. If A contains an even number of Is,
then P = 0.
The overflow flag is OV.
When the outcome of a signed number operation is too large and the high-order bit overflows
into the sign bit, this flag is set. The carry flag is typically used to identify mistakes in unsigned
arithmetic operations. Only signed arithmetic errors are detected using the overflow flag.

42) What is advantage of PCON register?


The 8051 Microcontroller's Power modes are controlled by the PCON or Power Control
register, which is found at address 87H of the SFR Memory Space. The microcontroller can
be configured to operate in Idle Mode or Power down Mode using two bits in the PCON
Register.
43) What different jump commands are there for microcontrollers?

There are two varieties of it: unconditional leap and conditional jump. There are two sorts of
conditional jumps: byte level instructions and bit level instructions. Similar unqualified leap is
further separated into the three sub-jumps of Short Jump, Absolute Jump, and Long Jump.

www.iies.in [email protected] +919886920008


44) What does the EA pin represent?

External Access is referred to as EA. By setting this pin to LOW, the 8051 stops using its internal
4KB on-chip ROM and switches to using only external memory as programme storage. When
HIGH is applied to this pin the 8051 starts using its own 4KB on chip ROM as well as external
memory to store program.

45) Define serial communication

A communication technique known as serial communication sends and receives data constantly,
one bit at a time, via one or two transmission lines.

46) Describe the Significance of RI and TI flags in 8051

The 8051 microcontroller features a serial port and associated serial interrupt flags (TI/RI). The TI
serial interrupt flag is set when the last bit (stop bit) of a byte is broadcast, and the RI flag is set
when the last bit (stop bit) of the receiving data byte is received.

47) Define bit, byte and nibble

Lengths of common binary numbers

In a binary number, each 1 or 0 is referred to as a bit. From then, a set of four bits is referred to as
a nibble, and an eight-bit unit is a byte. When working with binary, the word "bytes" is a very
prevalent buzzword.

48) List the types of addressing modes in 8051


8051 Six different addressing modes are available.
➢ Quick Addressing Mode
➢ Addressing Mode in Register
➢ Addressing Directly Mode
➢ Indirect Addressing Mode Registration
➢ Addressing Mode Indexed
➢ Addressing Mode Implied

www.iies.in [email protected] +919886920008


49) Explain TMOD register in 8051
For choosing a mode of operation and controlling a purpose, the 8051 provides a Timer Mode
Register and Timer Control Register. A timer0 and timer1's mode is set using the 8-bit register
TMOD. Bit 7, 3 - GATE: 1 = only when the INT0/INT1 pin is high and TR0/TR1 is set, the
timer/counter is enabled.

50) Which interrupt in the microcontroller has the highest priority?

The highest priority is the trap interrupt. A trap is an anomalous condition that the CPU detects
and signals, for example, when an unknown I/O device is accessed.

www.iies.in [email protected] +919886920008

You might also like