EMBEDDED SYSTEM & IoT
IAT -1
1. What is microcontroller?
A microcontroller is an integrated circuit (IC) device used for controlling
other portions of an electronic system, usually via a microprocessor unit
(MPU), memory, and some peripherals. These devices are optimized for
embedded applications that require both processing functionality and
agile, responsive interaction with digital, analog, or electromechanical
components.
2. Define PSW
PSW stands for Program Status Word. It's a special register within the central
processing unit (CPU) that acts like a flag register and a program counter
combined, although its specific functionality can vary slightly depending on the
particular architecture.
3. Differentiate C language and Embedded C
Feature C Language Embedded C
Develops software for embedded systems
Purpose General-purpose programming (microcontrollers)
Offers core programming constructs Extends C with features for hardware
Functionality (variables, functions, control flow) interaction and resource management
Hardware Hardware-dependent (specific to target
dependence Hardware-independent microcontroller)
Memory Uses dynamic memory allocation Focuses on static memory allocation
management (malloc, free) (limited resources)
Operating Typically operates without an operating
system Runs on various operating systems system (bare-metal programming)
Specialized compilers for specific
Compilers Standard C compilers microcontrollers
Offers various data types (int, float, May include additional data types like bit
Data types char) fields and fixed-point numbers
Desktop applications, games, system Device drivers, firmware for embedded
Applications programming devices, real-time systems
4. Define task and Process
Task:
Definition: A task is a specific, well-defined unit of work that needs to be
completed. It typically has a clear beginning and end, is atomic (meaning it cannot
be further divided), and contributes to achieving a larger goal.
Process:
Definition: A process is a sequence of well-defined, ordered steps that are taken
to achieve a specific business objective. It typically involves multiple tasks, often
interconnected and dependent on each other, and outlines the how something will
be achieved.
5. List out the need for RTOS
Real-time operating systems (RTOS) are essential for specific applications due to
their unique capabilities in handling time-sensitive tasks. Here are some key
reasons why RTOSes are necessary:
• Deterministic Behaviour
• Resource Management
• Event-Driven Operation
• Prioritization and Concurrency
6. Define Program Counter.
The program counter (PC), also commonly known as the instruction pointer (IP)
in some architectures, is a special register within the central processing unit (CPU) of
a computer. It acts like a pointer that keeps track of the memory address of the
next instruction to be executed in the program currently running on the CPU.
7. What is meant by DPTR?
DPTR stands for Data Pointer and is a special register found in the 8051-
microcontroller architecture. It's a 16-bit (2-byte) register, making it the only user-
accessible 16-bit register in the 8051 family.
8. Differentiate pre-emptive and Non pre-emptive Scheduling.
Feature Pre-emptive Scheduling Non-Pre-emptive Scheduling
Interrupting Can interrupt a running process when Cannot interrupt a running process; waits
process a higher priority process arrives until it finishes
More flexible as it prioritizes urgent Less flexible as lower priority tasks might
Flexibility tasks wait even when a higher priority arrives
Involves overhead for context
Overhead switching between processes No overhead for context switching
Generally better CPU utilization as
high priority tasks get served May lead to underutilization if a low priority
CPU utilization promptly process runs for a long time
Provides better response time for Response time for high priority tasks can be
Response time high priority tasks delayed if a low priority process is running
Example First Come First Serve (FCFS), Shortest
algorithms Round robin, Priority scheduling Job First (SJF) (non-pre-emptive version)
Real-time systems, multi-tasking
Applications environments Simple systems, batch processing
PART-B
9. Discuss in detail the addressing modes of 8051 microcontroller
The 8051 microcontroller utilizes several addressing modes to specify the location
of operands within instructions. These modes determine how the CPU retrieves data
for operations, offering flexibility and efficiency in program execution. Here's a
detailed discussion of each addressing mode:
1. Immediate Addressing:
• Description: The operand is directly specified within the instruction itself,
following the opcode. No additional memory access is required.
• Format: MOV A, #data (where data is the immediate value)
• Example: MOV A, #0xFF (moves the immediate value 0xFF to the accumulator
register A)
• Advantages: Simple and efficient for constant values, reduces memory
usage.
• Disadvantages: Limits the operand size to the instruction size (typically 1 or
2 bytes).
2. Register Addressing:
• Description: The operand is located in one of the internal CPU registers (A,
B, C, D, E, R0, R1, PSW).
• Format: MOV A, R0 (moves the content of register R0 to the accumulator
register A)
• Example: ADD A, R1 (adds the content of register R1 to the accumulator A)
• Advantages: Fastest access as registers are directly accessible by the CPU.
• Disadvantages: Limited to the available registers, cannot access data in
external memory.
3. Direct Addressing:
• Description: The operand is located in the internal RAM (data memory) of
the 8051, and its address is directly specified within the instruction.
• Format: MOV A, 30H (moves the value from memory address 30H to the
accumulator A)
• Example: ADD A, 45H (adds the value from memory address 45H to the
accumulator A)
• Advantages: Efficient for accessing data within internal RAM, allows direct
manipulation of memory locations.
• Disadvantages: Limited to the internal RAM address space (128 bytes).
4. Indirect Addressing:
• Description: The operand's address is stored in a register pair, and the CPU
uses this address to fetch the actual data value.
• Formats:
o MOV A, @R0 (uses the value in register pair R0 as the address to fetch
data for accumulator A)
o MOVX A, @DPTR (uses the 16-bit value in DPTR as the address to fetch
data for accumulator A)
• Example: MOV R0, #20H followed by MOV A, @R0 (first stores the address 20H
in R0, then uses R0 to fetch data from that address)
• Advantages: Enables accessing data anywhere in memory (including
external) indirectly through register pairs, useful for addressing large data
structures or tables.
• Disadvantages: Slightly slower than direct addressing due to an extra
memory access.
5. Indexed Addressing:
• Description: The operand's address is calculated by adding a constant
value (displacement) to the content of a register pair.
• Format: MOV A, 10H + DPTR (adds 10H to the value in DPTR and uses the
resulting address to fetch data for accumulator A)
• Example: MOV DPTR, #4000H followed by MOV A, 5H + DPTR (first sets DPTR
to 4000H, then adds 5H to it and uses the resulting address (4005H) to fetch
data)
• Advantages: Useful for accessing sequential data elements in memory,
allows addressing with an offset relative to a base address stored in a register
pair.
• Disadvantages: Slightly slower than direct addressing due to the addition
operation needed.
10. Explain how 8051 is interfaced with Memory and I/O Devices.
The 8051 microcontroller interacts with memory and I/O devices through a dedicated
set of pins and control signals. Here's a breakdown of the key mechanisms involved:
Memory Interfacing:
• Internal Memory: The 8051 has a limited amount of internal RAM (128 bytes)
for data storage. This memory is directly accessible by the CPU using its
addressing modes.
• External Memory: The 8051 can be interfaced with external memory devices
like RAM or ROM chips to expand its memory capacity. This interfacing
involves connecting the data bus, address bus, and control signals of the
8051 to the corresponding pins of the external memory chip.
• Data Bus: The data bus (typically 8 bits wide) carries the data being
transferred between the CPU and memory (internal or external).
• Address Bus: The address bus (typically 16 bits wide) specifies the memory
location from where data needs to be read or written. Due to limitations in the
number of address bus pins, the 8051 uses multiplexed addressing for
external memory. This means that the lower address bits (A0-A7) share the
same pins as the upper data bits (D8-D15) during certain operations.
Dedicated control signals indicate whether the pins are carrying data or
address information.
• Control Signals: Control signals like ALE (Address Latch Enable), PSEN
(Program Store Enable), RD (Read), and WR (Write) are used to
synchronize data transfer between the CPU and memory. These signals
control when addresses are latched, enable memory operations, and specify
whether data is being read from or written to memory.
I/O Interfacing:
• I/O Ports: The 8051 has four 8-bit I/O ports (P0, P1, P2, P3) that can be
configured as either inputs or outputs. These ports connect the microcontroller
to various external devices.
• Input/Output Modes: Each bit within an I/O port can be individually set as
input or output using specific control registers.
• Data Transfer: Data is transferred between the CPU and external devices
through these I/O ports. The CPU reads data from sensors or switches
connected to input pins and writes data to control LEDs, motors, or other
actuators connected to output pins.
• Special Function Registers (SFRs): The 8051 has dedicated SFRs that
control the configuration and operation of the I/O ports. These registers allow
setting pins as input or output, enabling pull-up resistors for inputs, and
controlling data latches.
PART-C
11. Explain in detail about the instruction set of 8051 microcontroller with
examples.
The 8051 microcontroller boasts a powerful and versatile instruction set (ISA) that
caters to various operations on data, program flow control, and interfacing with
external devices. Here's a detailed explanation of the 8051 instruction set with
examples:
Instruction Format:
Most 8051 instructions follow a basic format consisting of an opcode (operation
code) and optionally one or two operands. The opcode specifies the operation to be
performed, while the operands indicate the data sources or destinations. The size
and format of the operand(s) can vary depending on the specific instruction.
Instruction Categories:
The 8051 instruction set can be broadly categorized into the following groups:
1. Data Transfer Instructions: These instructions move data between various
sources and destinations, including registers, memory locations, and I/O
ports.
o Examples:
▪ MOV A, #data (Move immediate data to accumulator)
▪ MOV R0, DPTR (Move DPTR content to register R0)
▪ XCH A, R1 (Exchange the content of accumulator and register
R1)
2. Arithmetic and Logical Instructions: These instructions perform arithmetic
operations (addition, subtraction, multiplication, division) and logical
operations (AND, OR, NOT, XOR) on data.
o Examples:
▪ ADD A, #10 (Add immediate value 10 to accumulator)
▪ SUBB A, R2 (Subtract the content of register R2 from
accumulator with borrow)
▪ ANL A, P1 (Logical AND between accumulator and port P1)
3. Jump and Branch Instructions: These instructions control the program flow
by altering the execution sequence.
o Examples:
▪ SJMP address (Unconditional jump to a specific memory
address)
▪ JC address (Jump if Carry flag is set)
▪ JZ address (Jump if Zero flag is set)
4. Bit Manipulation Instructions: These instructions operate on individual bits
within a byte of data.
o Examples:
▪ SETB bit_number (Set a specific bit in the accumulator)
▪ CLR B3 (Clear bit number 3 in register B)
5. I/O Instructions: These instructions interact with external devices connected
to the I/O ports.
o Examples:
▪ SETB P1.2 (Set bit number 2 of port P1 as output)
▪ MOV P2, #0xFF (Write the value 0xFF to all bits of port P2)
Addressing Modes:
The 8051-instruction set utilizes various addressing modes that specify how
operands are located in memory or registers. These modes include:
• Immediate Addressing: Operand value is directly specified within the
instruction.
• Register Addressing: Operand resides in one of the CPU registers.
• Direct Addressing: Operand is located in a specific internal RAM address.
• Indirect Addressing: Operand's address is stored in a register pair.
• Indexed Addressing: Operand's address is calculated by adding a constant
value to a register pair content.