Embedded System (4343204) - Summer 2025 Solution

Solution guide for Embedded System (4343204) Summer 2025 exam

Question 1(a) [3 marks]

Discuss characteristics of real time operating system.

Answer:

Table: RTOS Characteristics

CharacteristicDescription
DeterministicPredictable response times
Time ConstraintsHard and soft deadlines
Priority SchedulingTask execution by priority
Resource ManagementEfficient memory and CPU usage
  • Deterministic behavior: System responds within guaranteed time limits
  • Multitasking support: Multiple tasks execute concurrently with priority
  • Interrupt handling: Fast response to external events

Mnemonic: "RTOS Delivers Tasks Properly"


Question 1(b) [4 marks]

Describe AVR I/O port registers.

Answer:

Table: AVR I/O Port Registers

RegisterFunctionAccess
DDRxData Direction RegisterRead/Write
PORTxPort Output RegisterRead/Write
PINxPort Input RegisterRead Only
  • DDRx register: Controls pin direction (0=input, 1=output)
  • PORTx register: Sets output values or enables pull-up resistors
  • PINx register: Reads current pin states for input operations

Mnemonic: "Direction, Port, Pin - DPP"


Question 1(c) [7 marks]

Compare different AVR microcontrollers and What are the factors to be considered in selecting the microcontroller for embedded system?

Answer:

Table: AVR Microcontroller Comparison

FeatureATmega8ATmega32ATmega128
Flash Memory8KB32KB128KB
SRAM1KB2KB4KB
EEPROM512B1KB4KB
I/O Pins233253
Timers334

Selection Factors:

  • Processing speed: Clock frequency requirements for application
  • Memory requirements: Program and data storage needs
  • I/O requirements: Number of pins needed for interfacing
  • Power consumption: Battery life considerations for portable devices
  • Cost factor: Budget constraints and volume requirements
  • Development tools: Availability of compilers and debuggers

Mnemonic: "Speed, Memory, I/O, Power, Cost, Tools - SMIPCT"


Question 1(c OR) [7 marks]

Draw and explain general block diagram of embedded system.

Answer:

Diagram:

goat

Components:

  • Input section: Sensors and switches provide data to system
  • Processing unit: Microcontroller executes program and controls operations
  • Output section: Displays results and controls external devices
  • Power supply: Provides regulated power to all components
  • Memory: Stores program code and data permanently
  • Communication: Interfaces with external systems via serial/wireless

Mnemonic: "Input, Process, Output, Power, Memory, Communication - IPOPMC"


Question 2(a) [3 marks]

Compare SRAM with EEPROM of ATMega32.

Answer:

Table: SRAM vs EEPROM Comparison

ParameterSRAMEEPROM
Size2KB1KB
VolatilityVolatileNon-volatile
Access SpeedFastSlow
Write CyclesUnlimited100,000 cycles
  • Data retention: SRAM loses data on power-off, EEPROM retains data
  • Usage purpose: SRAM for variables, EEPROM for configuration data

Mnemonic: "SRAM is Fast but Forgets, EEPROM Endures"


Question 2(b) [4 marks]

List Timer/counter 0 operation mode and explain anyone.

Answer:

Table: Timer0 Operation Modes

ModeNameDescription
0NormalCount up to 0xFF, overflow
1PWM Phase CorrectPWM with phase correction
2CTCClear Timer on Compare
3Fast PWMHigh frequency PWM

Normal Mode Explanation:

  • Counter operation: Counts from 0x00 to 0xFF continuously
  • Overflow flag: TOV0 flag set when counter overflows to 0x00
  • Interrupt generation: Can generate interrupt on overflow condition

Mnemonic: "Normal Counts, PWM Pulses, CTC Clears"


Question 2(c) [7 marks]

With a sketch, identify and write function of each pins of ATmega32.

Answer:

Diagram: ATmega32 Pin Configuration

goat

Pin Functions:

  • Port A: 8-bit ADC input pins (PA0-PA7)
  • Port B: SPI communication and timer functions
  • Port C: JTAG interface and I2C communication
  • Port D: UART communication and external interrupts
  • Power pins: VCC, GND, AVCC for analog supply
  • Crystal pins: XTAL1, XTAL2 for external oscillator

Mnemonic: "Analog-A, Bus-B, Communication-C, Data-D"


Question 2(a OR) [3 marks]

Explain data memory organization of ATmega32.

Answer:

Table: ATmega32 Memory Organization

Memory TypeAddress RangeSize
Registers0x00-0x1F32 bytes
I/O Registers0x20-0x5F64 bytes
Internal SRAM0x60-0x25F2048 bytes
  • General purpose registers: R0-R31 for arithmetic operations
  • I/O memory space: Control registers for peripherals
  • Internal SRAM: Variable storage during program execution

Mnemonic: "Registers, I/O, SRAM - RIS"


Question 2(b OR) [4 marks]

Draw TIFR and TCCR registers of timer/counter 0.

Answer:

Diagram: Timer0 Registers

goat

Bit Functions:

  • TOV0: Timer0 overflow flag bit
  • OCF0: Timer0 output compare match flag
  • CS02:CS00: Clock select bits for prescaler
  • WGM01:WGM00: Waveform generation mode bits

Mnemonic: "TIFR shows Flags, TCCR Controls Clock"


Question 2(c OR) [7 marks]

Draw and explain general block diagram of AVR microcontroller.

Answer:

Diagram: AVR Architecture

goat

Components:

  • CPU core: Executes instructions and controls system operation
  • Program memory: Stores application code in non-volatile flash
  • Data memory: Temporary storage for variables and stack
  • ALU: Performs arithmetic and logical operations
  • Register file: 32 general-purpose working registers
  • I/O system: Interfaces with external hardware components
  • Peripherals: Built-in modules like timers, UART, ADC

Mnemonic: "CPU Controls Program, Data, I/O, Peripherals - CPDIP"


Question 3(a) [3 marks]

Write an AVR C program to toggle all the bits of Port B continuously with a 10 ms delay.

Answer:

C

Key Points:

  • DDRB = 0xFF: Configures all Port B pins as outputs
  • PORTB toggle: Alternates between 0xFF and 0x00

Mnemonic: "DDR Direction, PORT Output"


Question 3(b) [4 marks]

Explain function of MAX232.

Answer:

Table: MAX232 Functions

FunctionDescription
Level ConversionTTL to RS232 voltage levels
Charge PumpGenerates ±10V from +5V supply
Line DriversTwo transmit drivers
Line ReceiversTwo receive receivers
  • Voltage conversion: Converts 0-5V TTL to ±12V RS232 levels
  • Serial communication: Enables microcontroller to communicate with PC
  • Dual channel: Supports two-way communication simultaneously

Mnemonic: "MAX232 Makes Microcontroller Meet PC"


Question 3(c) [7 marks]

Write AVR C program to toggle all the bits of PORTC continuously with some delay. Use timer 0, mode 0 and no prescalar options to generate delay.

Answer:

C

Key Features:

  • Timer0 normal mode: Counts from 0 to 255 then overflows
  • No prescaler: Timer runs at system clock speed
  • Overflow detection: TOV0 flag indicates timer overflow
  • Delay generation: Multiple timer cycles create visible delay

Mnemonic: "Timer Counts, Overflow Flags, Generate Delays"


Question 3(a OR) [3 marks]

Write AVR C program to store #30h into location 0X011F of EEPROM.

Answer:

C

Alternative Method:

C

Mnemonic: "Address, Data, Master, Write - ADMW"


Question 3(b OR) [4 marks]

Discuss different data types for programming AVR in C.

Answer:

Table: AVR C Data Types

Data TypeSizeRange
char1 byte-128 to 127
unsigned char1 byte0 to 255
int2 bytes-32768 to 32767
unsigned int2 bytes0 to 65535
long4 bytes-2³¹ to 2³¹-1
float4 bytesIEEE 754 format
  • Memory efficiency: Choose smallest suitable data type
  • Unsigned types: Use when negative values not needed
  • Integer arithmetic: Faster than floating-point operations

Mnemonic: "Choose Correct Size for Memory Efficiency"


Question 3(c OR) [7 marks]

Write AVR C programs for serial data transmission.

Answer:

C

Key Components:

  • Baud rate setting: UBRR registers set communication speed
  • Transmit enable: TXEN bit enables UART transmitter
  • Data transmission: UDR register holds data to transmit
  • Buffer check: UDRE flag indicates transmit buffer empty

Mnemonic: "Init, Enable, Check, Transmit - IECT"


Question 4(a) [3 marks]

Explain ADMUX register.

Answer:

Table: ADMUX Register Bits

BitNameFunction
REFS1:0Reference SelectVoltage reference selection
ADLARLeft AdjustResult left adjustment
MUX4:0Channel SelectADC input channel selection
  • Reference voltage: Selects internal/external voltage reference
  • Result format: ADLAR bit adjusts 10-bit result alignment
  • Channel selection: MUX bits choose which ADC pin to read

Mnemonic: "Reference, Adjust, Channel - RAC"


Question 4(b) [4 marks]

Draw and explain Interfacing Relay with ATmega32.

Answer:

Diagram: Relay Interfacing

goat

Components:

  • Transistor switch: BC547 NPN transistor acts as electronic switch
  • Base resistor: 1KΩ limits base current from microcontroller
  • Relay coil: 12V relay operates external high-power devices
  • Protection diode: Freewheeling diode protects from back EMF

Mnemonic: "Micro Controls Transistor Controls Relay"


Question 4(c) [7 marks]

Draw and explain TWI registers in AVR.

Answer:

Diagram: TWI Register Structure

goat

Register Functions:

  • TWCR: Controls TWI operation and interrupt handling
  • TWSR: Provides status information and prescaler setting
  • TWDR: Holds data for transmission/reception
  • TWAR: Sets slave address when operating as slave
  • TWBR: Sets bit rate for TWI communication
  • TWINT: Interrupt flag cleared by writing 1
  • Start/Stop: TWSTA and TWSTO control I2C conditions

Mnemonic: "Control, Status, Data, Address, Bit Rate - CSDAB"


Question 4(a OR) [3 marks]

Explain ADCSRA register.

Answer:

Table: ADCSRA Register Bits

BitNameFunction
ADENADC EnableEnables ADC module
ADSCStart ConversionStarts ADC conversion
ADATEAuto TriggerEnables auto trigger mode
ADIFInterrupt FlagADC conversion complete flag
ADIEInterrupt EnableEnables ADC interrupt
ADPS2:0PrescalerSets ADC clock prescaler
  • ADC control: ADEN enables ADC, ADSC starts conversion
  • Interrupt system: ADIF flag set when conversion complete

Mnemonic: "Enable, Start, Trigger, Interrupt, Prescale - ESTIP"


Question 4(b OR) [4 marks]

Draw and explain interfacing of LM35 with ATmega32.

Answer:

Diagram: LM35 Interfacing

goat

Connection Details:

  • Power supply: LM35 requires +5V and ground connections
  • Output voltage: Produces 10mV per degree Celsius
  • ADC input: Connect LM35 output to ADC channel (PA0)
  • Temperature calculation: °C = (ADC_Value × 5000mV) / (1024 × 10mV)

Code Example:

C

Mnemonic: "LM35 gives 10mV per degree"


Question 4(c OR) [7 marks]

Draw and explain interfacing of multiple 7-segment displays using MAX7221 with ATmega32.

Answer:

Diagram: MAX7221 Interfacing

goat

Features:

  • SPI communication: Uses serial peripheral interface for control
  • Multiple displays: Controls up to 8 seven-segment displays
  • Automatic scanning: MAX7221 handles multiplexing automatically
  • Brightness control: Software-controlled brightness levels
  • Decode mode: Built-in BCD to 7-segment decoder
  • Low component count: Reduces external components needed

Key Registers:

  • Decode mode register: Enables/disables BCD decoding
  • Intensity register: Controls display brightness
  • Scan limit register: Sets number of active displays
  • Shutdown register: Normal operation or shutdown mode

Mnemonic: "SPI Sends Serial Data to Multiple Displays"


Question 5(a) [3 marks]

Explain SPCR register.

Answer:

Table: SPCR Register Bits

BitNameFunction
SPIEInterrupt EnableEnables SPI interrupt
SPESPI EnableEnables SPI module
DORDData OrderLSB/MSB first selection
MSTRMaster/SlaveSelects master or slave mode
CPOLClock PolarityClock idle state selection
CPHAClock PhaseClock edge for data sampling
SPR1:0Clock RateSPI clock rate selection
  • SPI enable: SPE bit must be set to enable SPI functionality
  • Master mode: MSTR bit determines if device is master or slave

Mnemonic: "Interrupt, Enable, Data, Master, Clock settings - IEDMC"


Question 5(b) [4 marks]

Draw circuit diagram to interface DC motor with ATmega32 using L293D motor driver.

Answer:

Diagram: DC Motor Interfacing

goat

Components:

  • L293D driver: Provides current amplification for motor control
  • Power supplies: +5V for logic, +12V for motor power
  • Control signals: IN1, IN2 determine motor direction
  • Enable pin: EN1 controls motor on/off and speed (PWM)

Mnemonic: "Logic controls Direction, Enable controls Speed"


Question 5(c) [7 marks]

Explain IoT based Home Automation System.

Answer:

Diagram: IoT Home Automation System

goat

System Components:

  • Internet connectivity: WiFi module connects system to internet
  • Mobile application: User interface for remote control and monitoring
  • Sensor network: Temperature, motion, light sensors for automation
  • Control devices: Relays control home appliances and lights
  • Central controller: Microcontroller processes commands and sensor data
  • Cloud services: Store data and enable remote access

Features:

  • Remote control: Control appliances from anywhere via internet
  • Automation: Automatic control based on sensor readings
  • Energy saving: Smart scheduling reduces power consumption
  • Security monitoring: Motion sensors and cameras for safety
  • Data logging: Historical data storage for analysis

Mnemonic: "Internet connects Phones to Home Devices - IPHD"


Question 5(a OR) [3 marks]

Explain SPSR register.

Answer:

Table: SPSR Register Bits

BitNameFunction
SPIFInterrupt FlagSPI transfer complete flag
WCOLWrite CollisionData collision error flag
SPI2XDouble SpeedDoubles SPI clock rate
  • Transfer complete: SPIF flag indicates SPI transmission finished
  • Collision detection: WCOL flag shows write collision occurred
  • Speed control: SPI2X doubles communication speed when set

Mnemonic: "Flag, Collision, Speed - FCS"


Question 5(b OR) [4 marks]

Draw and explain pin diagram of L293D motor driver IC.

Answer:

Diagram: L293D Pin Configuration

goat

Pin Functions:

  • Enable pins (EN1, EN2): Control motor on/off and speed via PWM
  • Input pins (IN1-IN4): Logic inputs from microcontroller
  • Output pins (OUT1-OUT4): High current outputs to motors
  • Power supply (VCC1): +5V logic supply for IC operation
  • Motor supply (VCC2): +12V supply for motor power
  • Ground pins: Multiple ground connections for heat dissipation

Features:

  • Dual H-bridge: Can control two DC motors simultaneously
  • Current capacity: 600mA per channel, 1.2A peak
  • Protection: Built-in flyback diodes for motor protection

Mnemonic: "Enable, Input, Output, Power - EIOP"


Question 5(c OR) [7 marks]

Explain Motorised Control Robotics System.

Answer:

Diagram: Robotics Control System

goat

System Components:

Table: Robotics System Elements

ComponentFunctionExamples
SensorsEnvironment sensingUltrasonic, IR, Camera
ControllerDecision makingATmega32, Arduino
ActuatorsPhysical movementMotors, Servos
CommunicationRemote controlBluetooth, WiFi
PowerEnergy supplyBattery, Regulators
FeedbackPosition sensingEncoders, Gyroscope

Control Algorithm:

  • Sense: Collect data from environment using sensors
  • Process: Analyze sensor data and make decisions
  • Act: Control motors and actuators based on decisions
  • Feedback: Monitor actual movement and adjust control
  • Communicate: Send status and receive commands remotely

Applications:

  • Autonomous navigation: Robot moves independently using sensors
  • Object manipulation: Gripper controlled for pick and place tasks
  • Remote operation: Manual control via wireless communication
  • Path following: Line following or predetermined route navigation
  • Obstacle avoidance: Dynamic path planning around obstacles

Programming Structure:

C

Mnemonic: "Sense, Process, Act, Feedback, Communicate - SPACF"