Interview Level 8051 MCU
Interview Level 8051 MCU
Interview Level 8051 MCU
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.
Document Contents:
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.
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.
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,
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.
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.
The majority of possible operations on the Intel 8051 are 8-bit operations just because it is an 8-
bit microcontroller.
➢ 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?
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.
The only directive that allows for the definition of ASCII strings with more than two characters is
this one.
The assembler directive EQU is used to define constants without taking up memory space.
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.
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.
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.
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.
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.
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.
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.
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,
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.
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.
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.
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.
26) Can the 8051 be interfaced with all of the external data memory?
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.
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.
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.
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?
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.
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.
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.
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.
39) Where Do Data Memory Space And Code Memory Space Start?
For internal or external memory, at position 0x00
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.
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.
A communication technique known as serial communication sends and receives data constantly,
one bit at a time, via one or two transmission lines.
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.
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.
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.