ESY(22532)
1
Q1.Define RISC and CISC.
RISC (Reduced Instruction Set Computer):
RISC is a CPU architecture that uses a small set of simple instructions,
where each instruction is executed in one clock cycle. It focuses on high
performance and efficiency with simpler hardware design.
Example: ARM, MIPS.
CISC (Complex Instruction Set Computer):
CISC is a CPU architecture with a large set of complex instructions that can
perform multiple operations in a single instruction. It reduces the number of
instructions per program but has more complex hardware.
Example: Intel x86, AMD.
Q2.Compare Harvard vs. Von Neumann architecture.
ESY(22532)
2
Q 3.List four types of embedded systems with
examples.
1. Real-Time Embedded Systems
Definition: Systems that respond to inputs within a strict time limit.
Example: Anti-lock braking system (ABS) in cars.
2. Standalone Embedded Systems
ESY(22532)
3
Definition: Operate independently without needing a host system.
Example: Washing machines, microwave ovens.
3. Networked Embedded Systems
Definition: Connected to a network to access resources or data.
Example: Smart thermostats, IoT-based home automation.
4. Mobile Embedded Systems
Definition: Portable systems with limited resources and mobility.
Example: Smartphones, digital cameras.
Q4.Write a C program to:Toggle all bits of Port 1 with a
60ms delay (use Timer 0, Mode 1).
#include <reg51.h> // Include register definitions for 8051
// Function to generate a 60 ms delay using Timer 0 in Mode 1
void Timer0_Delay60ms() {
TMOD = 0x01; // Set Timer 0 in Mode 1 (16-bit mode)
// For 60 ms delay at 11.0592 MHz:
// Machine cycle = 1.085 µs
// Required counts = 60,000 µs / 1.085 µs ≈ 55248
// 65536 - 55248 = 10288 = 0x2820
TH0 = 0x28; // Load high byte
TL0 = 0x20; // Load low byte
TR0 = 1; // Start Timer 0
while (TF0 == 0); // Wait for Timer 0 overflow
TR0 = 0; // Stop Timer 0
TF0 = 0; // Clear Timer 0 overflow flag
}
ESY(22532)
4
// Main function
void main() {
while (1) {
P1 = ~P1; // Toggle all bits of Port 1
Timer0_Delay60ms(); // Delay 60 ms
}
}
Q5.Explain the TMOD register format.
TMOD Register Format
The TMOD register is an 8-bit register used to configure Timer 0 and Timer
1 in the 8051 microcontroller. This register sets the mode of operation and
control flags for both timers.
ESY(22532)
5
ESY(22532)
6
Q6.Write a C program to: Mask upper 4 bits of P0 and
lower 4 bits of P2.
#include <reg51.h> // Include 8051 register definition file
void main() {
unsigned char temp;
// Mask upper 4 bits of P0 (retain lower 4 bits)
temp = P0 & 0x0F; // 0x0F = 00001111
P0 = temp;
// Mask lower 4 bits of P2 (retain upper 4 bits)
temp = P2 & 0xF0; // 0xF0 = 11110000
P2 = temp;
while (1); // Infinite loop to keep the program running
}
Explanation:
P0 & 0x0F: Masks upper 4 bits of Port 0 (makes them 0) and retains the
lower 4 bits.
P2 & 0xF0: Masks lower 4 bits of Port 2 (makes them 0) and retains the
upper 4 bits.
Q7.Write a C program to:
Send "MSBTE" serially at 9600 baud (XTAL=11.0592
MHz).
#include <reg51.h>
ESY(22532)
7
void serial_init() {
TMOD = 0x20; // Timer1 in Mode 2 (8-bit auto-reload)
TH1 = 0xFD; // Load value for 9600 baud rate (for 11.0592 MHz)
SCON = 0x50; // Serial mode 1 (8-bit), REN enabled
TR1 = 1; // Start Timer1
}
void serial_transmit(unsigned char ch) {
SBUF = ch; // Load data into serial buffer
while (TI == 0); // Wait until transmission complete
TI = 0; // Clear transmit interrupt flag
}
void main() {
unsigned char msg[] = "MSBTE";
int i;
serial_init(); // Initialize serial communication
for (i = 0; msg[i] != '\0'; i++) {
serial_transmit(msg[i]); // Send each character
}
while (1); // Infinite loop
}
Explanation:
TMOD = 0x20: Sets Timer1 in 8-bit auto-reload mode.
TH1 = 0xFD: Load value to get 9600 baud rate (calculated for 11.0592
MHz).
SCON = 0x50: Enables serial mode 1 and reception.
ESY(22532)
8
SBUF: Serial buffer register to send characters.
TI: Transmit Interrupt flag.
Q8 Draw and explain:
16×2 LCD interfacing with 89C51 (RS, R/W, EN
functions). Also genrat diagrams images
1. Components Used
AT89C51 Microcontroller
16x2 Alphanumeric LCD
Resistors, Potentiometer (for contrast), and connecting wires.
2. LCD Pins & Their Roles
Pin No Name Function
1 VSS Ground(0v)
2 VDD +5v power supply
3 VEE Contrast adjustment(via potentiometer)
4 RS Register select (command/Data control)
5 R/W Read/Write control
6 EN Enable(used and latch data)
7-14 D0-D7 Data pins
15-16 LED +/- Backlight
3. Important Control Pins
RS (Register Select):
ESY(22532)
9
RS = 0: Command register (instructions like clear screen, cursor position).
RS = 1: Data register (send characters to be displayed).
R/W (Read/Write):
R/W = 0: Write operation.
R/W = 1: Read operation.
Usually grounded (0) for writing only.
EN (Enable):
High-to-Low transition triggers LCD to latch data present on the data lines.
4. Interfacing Details
Connect P2.0–P2.7 of 89C51 to D0–D7 of LCD.
Connect RS to P3.6, R/W to GND (write only), EN to P3.7.
Use a 10k potentiometer between VSS and VDD, wiper to VEE.
5. Diagram of 16x2 LCD Interfacing with 89C51
ESY(22532)
10
Q9.Draw and explain ADC 0808 interfacing** (explain
SOC, EOC, OE pins).
1. ADC 0808
ADC0808 is an 8-bit analog-to-digital converter with:
8-channel analog input multiplexer
Successive approximation conversion
Operates on a single 5V supply
2. Key Pins Explained
Pin Name Function
ESY(22532)
11
SOC Start of Conversion A low pulse start the ADC
conversion
EOC End of Conversion Goes HIGH when conversion is
complete
EO Output Enable When HIGH, allows data to be
read on D0-D7
3. Interfacing Overview
Analog input connected to any of IN0–IN7.
Microcontroller initiates conversion via SOC.
Waits for EOC to go HIGH, then reads data.
OE is set HIGH to enable the output data lines (D0–D7).
4. Typical Interfacing with 89C51
Connect D0–D7 of ADC0808 to Port 1 of 89C51.Connect SOC, OE to any
Port 3 pins (e.g., P3.0, P3.1).
Connect EOC to an input pin like P3.2.
5. Functional Flow
ESY(22532)
12
1. Select analog channel (via address pins A, B, C).
2. Give LOW-HIGH-LOW pulse to SOC to start conversion.
3. Wait until EOC goes HIGH.
4. Set OE HIGH, then read data from D0–D7.
6.DIAGRAM
Q.10.Explain DAC interfacing to generate
square/triangular wave with diagram.
Introduction:
ESY(22532)
13
DAC (Digital-to-Analog Converter) is used to convert digital signals from a
microcontroller into analog voltage. By sending sequences of digital values,
we can generate waveforms like square and triangular waves.
1. Interfacing DAC with Microcontroller:
An 8-bit DAC like DAC0808 can be interfaced with microcontroller through
its 8 digital input pins (D0–D7). The analog output is taken from the Vout
pin.
2. Square Wave Generation:
A square wave alternates between high (e.g. 5V) and low (e.g. 0V) levels.
Send maximum value (e.g. 0xFF) and minimum value (0x00) alternately to
DAC.
Delay between changes controls the frequency.
Example Code Logic:
while(1) {
DAC = 0xFF;
delay();
DAC = 0x00;
delay();
}
4. Circuit Diagram:
Conclusion:
ESY(22532)
14
Using DAC interfacing, we can easily generate analog wavefo
rms like square
and triangular waves by sending appropriate digital sequences through the
microcontroller.
Q11.Interface a 4×4 matrix keyboard with 89C51.
Introduction:
A 4×4 matrix keyboard consists of 16 keys arranged in 4 rows and 4
columns. Each key is placed at the intersection of a row and column. The
keyboard can be interfaced with the 89C51 microcontroller to detect key
presses.
1. Matrix Keyboard Connections:
4 Row Lines (R0–R3) and 4 Column Lines (C0–C3).
ESY(22532)
15
Total 8 lines are connected to the microcontroller I/O pins (usually Port 1 or
Port 2).
Pressing a key connects one row and one column together.
2. Interfacing Logic:
Set rows as outputs and columns as inputs.
Drive each row LOW one by one while keeping others HIGH.
Read the columns: if any column reads LOW, a key at that row-column
junction is pressed.
Use scanning method to detect key press and decode which key.
3. Interfacing Diagram:
ESY(22532)
16
4. Key Scanning Algorithm:
1. Set column pins (P1.4 to P1.7) as input (with pull-ups).
2. Drive one row LOW at a time.
3. Check column inputs:
If any column reads LOW, corresponding key is pressed.
4. Identify row and column to decode key.
5. Apply debouncing delay to avoid false triggering.
5. Sample Code (Concept):
void scan_keypad() {
for(row = 0; row < 4; row++) {
ESY(22532)
17
P1 = ~(1 << row); // Drive one row LOW
col = P1 >> 4; // Read upper 4 bits (columns)
if(col != 0x0F) {
// A key is pressed
delay(); // Debounce
// Decode key using row & column
}
}
}
Conclusion:
Interfacing a 4×4 matrix keyboard with 89C51 allows the microcontroller to
accept input from up to 16 keys using just 8 I/O pins. It's commonly used in
embedded systems like calculators, security systems, etc.
Q12.Explain CAN bus protocol (frame format +
applications).
CAN Bus Protocol
CAN (Controller Area Network) is a serial communication protocol designed
for high-speed, real-time communication between multiple devices (called
nodes) in automobiles and industrial systems. It is message-based rather
than address-based, meaning each message carries an identifier that
defines its priority and content.
Frame Format of CAN (Standard 11-bit Identifier)
1. Start of Frame (1 bit) – Indicates the beginning of a message.
2. Identifier (11 bits) – Unique ID for the message, also used for priority
arbitration.
ESY(22532)
18
3. RTR (1 bit) – Remote Transmission Request (0 for data frame, 1 for
remote frame).
4. IDE (1 bit) – Identifier Extension bit (0 for standard frame, 1 for extended
frame).
5. Reserved bit (1 bit) – Reserved for future use.
6. DLC – Data Length Code (4 bits) – Specifies number of data bytes (0 to
8.)
7. Data field (0–64 bits) – Contains the actual data (up to 8 bytes).
8. CRC (15 bits + 1 delimiter) – Error detection using a Cyclic Redundancy
Check.
9. ACK (2 bits) – Acknowledgment field (1 bit sent, 1 bit received).
10. End of Frame (7 bits) – Indicates end of the message.
Applications of CAN Protocol
1. Automobiles – Communication between engine control unit (ECU),
airbag, ABS, sensors, etc.
2. Industrial Automation – Connecting sensors, actuators, and
controllers.
3. Medical Equipment – Real-time data sharing in monitoring devices.
4. Aerospace – Control systems in aircrafts.
5. Agriculture & Marine Vehicles – Machinery and navigation control.
6. Building Automation – HVAC, lighting, and security systems.
Q13.Compare I²C and CAN protocols.
ESY(22532)
19
Q14.State two features each of:
ESY(22532)
20
USB, RS-232, Zigbee, Bluetooth.
USB (Universal Serial Bus)
1. High Data Transfer Rate – Supports speeds up to 10 Gbps (USB 3.1 and
above).
2. Plug and Play – Devices are auto-detected and configured without
restarting the system.
RS-232
1. Simple Serial Communication – Uses single-ended signaling, ideal for
short-distance device communication.
2. Low-Speed Transmission – Typically supports up to 115.2 kbps over
short distances (~15 meters).
Zigbee
1. Low Power Consumption – Ideal for battery-powered IoT devices.
2. Mesh Networking Support – Devices can relay data to extend network
range and reliability.
Bluetooth
1. Short-Range Wireless Communication – Operates typically within 10
meters.
2. Low Power and Cost – Suitable for wireless peripherals like
headphones, keyboards, and smart devices.
ESY(22532)
21
Q15.Define:
Reliability and Scalability in RTOS.
Reliability in RTOS:
The ability of an RTOS to consistently perform its intended
operations correctly and without failure over time.
Scalability in RTOS:
The ability of an RTOS to efficiently adapt to different
system sizes, hardware platforms, and application
complexities.
Q16.Define:
Deadlock,reasons and prevention methods.
Deadlock (Definition):
A deadlock is a condition in which two or more processes
are waiting indefinitely for resources that are held by each
other, causing all processes to be blocked permanently.
Reasons for Deadlock: (Necessary Conditions)
1. Mutual Exclusion – Only one process can use a
resource at a time.
ESY(22532)
22
2. Hold and Wait – A process is holding at least one
resource and waiting for others.
3. No Preemption – Resources cannot be forcibly taken
from a process.
4. Circular Wait – A circular chain of processes exists,
each waiting for a resource held by the next.
Deadlock Prevention Methods:
1. Avoid Mutual Exclusion – Share resources where
possible.
2. Avoid Hold and Wait – Require processes to request
all resources at once.
3. Allow Preemption – Temporarily take resources from a
process.
4. Avoid Circular Wait – Impose an ordering on resource
allocation.
Q17. Explain Preemptive vs Round Robin scheduling
Preemptive Scheduling:
The CPU can be taken from a running process if a higher-priority process
arrives.
Ensures better responsiveness for critical tasks.
Examples: Preemptive Priority Scheduling, Shortest Remaining Time First
(SRTF).
ESY(22532)
23
Round Robin Scheduling:
A type of preemptive scheduling where each process gets a fixed time
quantum.
After the quantum expires, the process is preempted and placed at the end
of the queue.
Ensures fairness and equal CPU time for all processes.
Key Differences:
Preemptive Scheduling is based on priority or time, while Round Robin
uses fixed time slices in a cyclic order.
Round Robin is simpler and fairer, but may involve more context switches
if the time quantum is too small.
Comparison Table:
ESY(22532)
24
Q18 Draw the block diagram of an embedded system
ESY(22532)
25
Q19.List design metrics (NRE cost, power, memory).
1. NRE Cost (Non-Recurring Engineering Cost):
One-time cost for research, development, design, and testing.
Includes salaries, prototyping, and tooling.
2. Power Consumption:
Important for battery-powered and energy-efficient systems.
Measured in watts (W) or milliwatts (mW).
3. Memory Usage:
Amount of RAM/ROM or storage required by the system.
Affects performance and cost.
Q20.Write a C program to rotate a stepper motor
(clockwise, 4-step sequence).
#include <reg51.h>
#include <intrins.h>
void delay() {
int i, j;
for (i = 0; i < 200; i++)
for (j = 0; j < 200; j++);
}
void main() {
// 4-step clockwise sequence: A B C D = P2.0 to P2.3
ESY(22532)
26
unsigned char stepper[4] = {0x09, 0x08, 0x0C, 0x04};
// 0x09 = 00001001, 0x08 = 00001000, etc.
int i;
while (1) {
for (i = 0; i < 4; i++) {
P2 = stepper[i];
delay();
}
}
}
Explanation:
P2 is used to send signals to the stepper motor via driver IC (like
ULN2003).
The 4-step sequence for clockwise rotation is:
1. A and D ON (P2.0 and P2.3)
2. D ON (P2.3)
3. C and D ON (P2.2 and P2.3)
4. C ON (P2.2)