Skip to main content
  1. Resources/
  2. Study Materials/
  3. Information & Communication Technology Engineering/
  4. ICT Semester 4/
  5. Embedded Systems (4343204)/

Embedded System (4343204) - Summer 2024 Solution

16 mins· ·
Study-Material Solutions Embedded-System 4343204 2024 Summer
Milav Dabgar
Author
Milav Dabgar
Experienced lecturer in the electrical and electronic manufacturing industry. Skilled in Embedded Systems, Image Processing, Data Science, MATLAB, Python, STM32. Strong education professional with a Master’s degree in Communication Systems Engineering from L.D. College of Engineering - Ahmedabad.
Table of Contents

Embedded System (4343204) - Summer 2024 Solution
#

Question 1(a) [3 marks]
#

Draw AVR status register.

Answer:

The AVR Status Register (SREG) contains information about the result of arithmetic operations and controls interrupts.

Diagram:

I7T6H5S4V3N2Z1C0
  • I (bit 7): Global Interrupt Enable
  • T (bit 6): Bit Copy Storage
  • H (bit 5): Half Carry Flag
  • S (bit 4): Sign Flag (S = N⊕V)
  • V (bit 3): Two’s Complement Overflow
  • N (bit 2): Negative Flag
  • Z (bit 1): Zero Flag
  • C (bit 0): Carry Flag

Mnemonic: “I Take Health Seriously, Very Nice Zero Carry”

Question 1(b) [4 marks]
#

Explain Harvard Architecture in the AVR.

Answer:

Harvard Architecture in AVR separates program and data memory, allowing simultaneous access to both.

Diagram:

graph TD
    CPU[CPU]
    PM[Program Memory]
    DM[Data Memory]
    CPU -->|Instruction Bus| PM
    CPU -->|Data Bus| DM
  • Program Memory: Stores instructions in Flash memory
  • Data Memory: Contains SRAM, registers, and I/O registers
  • Separate Buses: Different buses for program and data
  • Parallel Access: Can fetch instruction and access data simultaneously

Mnemonic: “Separate Places for Data And Programs”

Question 1(c) [7 marks]
#

Discuss real time operating system.

Answer:

Real-Time Operating System (RTOS) manages tasks with strict timing requirements, ensuring predictable response times.

Table: Key Features of RTOS

FeatureDescription
Task SchedulingPrioritizes tasks based on urgency
DeterministicGuaranteed response times for events
PreemptiveCritical tasks can interrupt lower priority ones
Memory ManagementEfficient memory allocation without fragmentation
Low LatencyMinimal delay between event and response
MultitaskingHandles multiple tasks concurrently
  • Task-based: Divides program into independent tasks
  • Interrupt Handling: Fast response to external events
  • Synchronization: Provides semaphores and mutexes for task coordination
  • Resource Management: Prevents resource conflicts
  • Small Footprint: Optimized for limited hardware resources

Mnemonic: “Tasks Run On Strict Timelines”

Question 1(c OR) [7 marks]
#

Discuss criteria for choosing microcontroller for embedded system.

Answer:

Selecting the right microcontroller requires evaluating several key factors to match application requirements.

Table: Microcontroller Selection Criteria

CriterionConsiderations
Processing PowerCPU speed, bit width (8/16/32-bit)
MemoryFlash, RAM, EEPROM sizes
Power ConsumptionSleep modes, operating voltage
I/O CapabilitiesNumber of ports, special functions
PeripheralsTimers, ADC, communication interfaces
CostUnit price, development tools cost
Development SupportTools, documentation, community
  • Application Needs: Match controller to task complexity
  • Real-time Requirements: Response time constraints
  • Environmental Factors: Temperature, noise, vibration
  • Form Factor: Physical size and packaging
  • Future Expansion: Room for feature growth

Mnemonic: “Power, Memory, I/O, Peripherals, Cost”

Question 2(a) [3 marks]
#

Define embedded system and draw its general block diagram.

Answer:

An embedded system is a dedicated computer system designed for specific functions within a larger mechanical or electrical system.

Diagram:

IDSneepvnuistcoerssPUMPSrneouoimwpctoeperrlsyysingODAuectvtpiuucatetsors
  • Processing Unit: Microcontroller/microprocessor
  • Memory: Stores program and data
  • Input/Output: Interfaces with external world

Mnemonic: “Processing Memory I/O Power”

Question 2(b) [4 marks]
#

List I/O registers associated with each port.

Answer:

AVR microcontrollers have three primary registers for controlling each I/O port.

Table: I/O Port Registers

RegisterFunctionDescription
PORTxData RegisterSets output values or pull-ups
DDRxData Direction RegisterSets pin direction (1=output, 0=input)
PINxPort Input PinsReads actual pin status
  • x represents: A, B, C, D (port letter)
  • Additional Special: Some ports have PCMSK (Pin Change Mask) registers

Mnemonic: “Direction, Data, Pin reading”

Question 2(c) [7 marks]
#

Explain clock and reset circuit for AVR.

Answer:

The clock and reset circuits ensure proper initialization and timing of AVR operations.

Clock Circuit Diagram:

XTAL1XATGVANRLDXTAL2

Reset Circuit:

RVEACSVCERT10CKΩGND
  • Clock Source: External crystal, RC oscillator, or internal oscillator
  • Crystal: Provides accurate timing (1-16 MHz)
  • Reset Pin: Active-low input for system restart
  • Power-on Reset: Automatic reset when power applied
  • Brown-out Detection: Reset if voltage drops below threshold

Mnemonic: “Crystal Oscillates, Reset Ensures Start”

Question 2(a OR) [3 marks]
#

Write characteristics of embedded system.

Answer:

Embedded systems have unique characteristics that distinguish them from general-purpose computers.

Table: Embedded System Characteristics

CharacteristicDescription
Single-FunctionDedicated to specific tasks
Real-timePredictable response times
Resource ConstrainedLimited memory, power, processing
ReliabilityMust operate continuously without fail
ReactiveResponds to environmental changes
  • Long Life: Often operates for years without intervention
  • Often Hidden: Integrated within larger systems

Mnemonic: “Single, Real-time, Resource-limited, Reliable”

Question 2(b OR) [4 marks]
#

Discuss the role of DDRx in outputting and inputting data.

Answer:

DDRx (Data Direction Register) configures each pin of port x as either input or output.

Table: DDRx Role in I/O Operations

DDRx ValuePORTx ValueModeFunction
00InputHigh-impedance mode
01InputPull-up enabled
10OutputOutput low (0V)
11OutputOutput high (VCC)
  • Direction Control: 1 = output, 0 = input
  • Pin-specific: Each bit controls individual pin
  • Initial State: Default is input (all 0s)

Mnemonic: “Direction Determines Data flow”

Question 2(c OR) [7 marks]
#

Draw and explain ATmega32 pin diagram.

Answer:

ATmega32 is a popular 8-bit AVR microcontroller with 40 pins providing various functionalities.

Diagram:

(((((IIOO(I(((NNCCINORTTT11CTCXX01BAP20DD)))))//))(AAPPPPPXIIRXXPPDDDDDCNNMMETTDD23456K01OISSVGAA01)P))SSSCECNLLBSIOKTCD21P1PPBBBPPPP11112023BBBB1167890456745|9111120123222221342254321567876333223210984933PPPPP0|873333PPCCCCD|-6543CC32107-AGAPP54PRNVCC(PAPPEDC76OA1AAPPPPFCC023AAAA((2(4567TT)(A((OOADAA((((SSDCDDAAAACCC1CCDDDD210)23CCCC)))))4567))))
  • Port A (PA0-PA7): 8-bit bidirectional port with ADC inputs
  • Port B (PB0-PB7): 8-bit port with SPI, timers, and external interrupts
  • Port C (PC0-PC7): 8-bit bidirectional port with TWI support
  • Port D (PD0-PD7): 8-bit port with USART, external interrupts, and PWM
  • Power/Ground: VCC, GND, AVCC, AREF
  • Clock: XTAL1/XTAL2 for external oscillator
  • Reset: Active-low reset input

Mnemonic: “ABCD Ports Around Power Clock Reset”

Question 3(a) [3 marks]
#

Explain Program Counter (PC) register for ATmega32.

Answer:

Program Counter (PC) is a 16-bit register that tracks the address of the next instruction to execute.

Diagram:

PC1H5i:g8h|PC7:L0ow|
  • Function: Points to next instruction in program memory
  • Size: 16-bit (can address up to 64K words)
  • Auto-increment: Automatically increments after instruction fetch
  • Jump Control: Modified by branch and jump instructions

Mnemonic: “Points to Code Execution”

Question 3(b) [4 marks]
#

Write an AVR C program to read the content of location 0x005F of EEPROM into PORTB.

Answer:

#include <avr/io.h>
#include <avr/eeprom.h>

int main(void)
{
    // Set PORTB as output
    DDRB = 0xFF;
    
    // Read from EEPROM location 0x005F and output to PORTB
    PORTB = eeprom_read_byte((uint8_t*)0x005F);
    
    while(1) {
        // Main loop
    }
    return 0;
}
  • DDRB = 0xFF: Configure all PORTB pins as outputs
  • eeprom_read_byte(): AVR library function to read EEPROM
  • while(1): Infinite loop to maintain output

Mnemonic: “Direction, Read EEPROM, Output to Port”

Question 3(c) [7 marks]
#

Draw and explain TCCR0 register in detail.

Answer:

Timer/Counter Control Register 0 (TCCR0) controls the operation of Timer/Counter0.

Diagram:

FO7C0WG6M00|C5OM01|C4OM00|W3GM01|2CS02|1CS01|0CS00|

Table: TCCR0 Bits Function

Bit(s)NameFunction
7FOC0Force Output Compare
6,3WGM01:0Waveform Generation Mode
5,4COM01:0Compare Match Output Mode
2,1,0CS02:0Clock Select
  • WGM01:0: Selects Normal, CTC, or PWM modes
  • COM01:0: Defines OC0 pin behavior on compare match
  • CS02:0: Sets clock source and prescaler (1, 8, 64, 256, 1024)

Mnemonic: “Forcing Waveforms, Comparing, Selecting Clock”

Question 3(a OR) [3 marks]
#

Explain AVR data memory.

Answer:

AVR data memory consists of multiple sections for different types of data storage.

Diagram:

graph TD
    A[AVR Data Memory]
    A --> B[Registers]
    A --> C[I/O Registers]
    A --> D[Internal SRAM]
    A --> E[EEPROM]
  • Registers: 32 general-purpose registers (R0-R31)
  • I/O Memory: Special function registers for peripherals
  • SRAM: Internal RAM for variables (volatile)
  • EEPROM: Non-volatile memory for persistent data

Mnemonic: “Registers I/O SRAM EEPROM”

Question 3(b OR) [4 marks]
#

Write an AVR C program to store ‘G’ into location 0x005F of EEPROM.

Answer:

#include <avr/io.h>
#include <avr/eeprom.h>

int main(void)
{
    // Store character 'G' to EEPROM location 0x005F
    eeprom_write_byte((uint8_t*)0x005F, 'G');
    
    while(1) {
        // Main loop
    }
    return 0;
}
  • eeprom_write_byte(): AVR library function to write to EEPROM
  • ‘G’: ASCII value 71 (0x47) stored in EEPROM
  • 0x005F: Target EEPROM address
  • while(1): Infinite loop after writing

Mnemonic: “Write Once, Remember Forever”

Question 3(c OR) [7 marks]
#

Draw and explain TIFR register in detail.

Answer:

Timer/Counter Interrupt Flag Register (TIFR) holds flags that indicate timer events.

Diagram:

76543OCF22TOV12TOV00

Table: TIFR Bits Function

BitNameFunction
0TOV0Timer/Counter0 Overflow Flag
1TOV2Timer/Counter2 Overflow Flag
2OCF2Output Compare Flag 2
3-7-Reserved bits
  • TOV0: Set when Timer0 overflows, cleared when ISR executes
  • TOV2: Set when Timer2 overflows
  • OCF2: Set when Timer2 compare match occurs
  • Flag Clearing: Write ‘1’ to bit to clear flag

Mnemonic: “Timers Overflow, Comparisons Flag”

Question 4(a) [3 marks]
#

Write different ways of generating delay in AVR.

Answer:

AVR microcontrollers offer multiple methods to generate time delays.

Table: Delay Generation Methods

MethodDescriptionPrecision
Software LoopsCPU cycles countingLow
Timer InterruptsHardware timers with ISRHigh
Timer PollingHardware timers with flag checkingMedium
Delay FunctionsLibrary functions (_delay_ms/_delay_us)Medium
  • Software: Simple but affected by optimizations
  • Hardware: More accurate but requires timer setup
  • Library: Convenient but limited to constant values

Mnemonic: “Loops, Interrupts, Polling, Functions”

Question 4(b) [4 marks]
#

Draw and explain interfacing of LM35 with ATmega32.

Answer:

LM35 is a temperature sensor that outputs an analog voltage proportional to temperature.

Circuit Diagram:

VLCMGC3N5D+5V)ToADC0(PA0)
  • Connection: LM35 output to ADC0 (PA0) of ATmega32
  • Scaling: 10mV/°C output (0°C = 0V, 25°C = 250mV)
  • ADC Setup: Configure ADMUX to select ADC0
  • Calculation: Temperature = (ADC_value * 5 * 100) / 1024

Mnemonic: “Analog Voltage Converts Temperature”

Question 4(c) [7 marks]
#

Explain interfacing of MAX7221 with ATmega32 in detail.

Answer:

MAX7221 is an LED display driver IC that connects to AVR using SPI communication.

Circuit Diagram:

ATmegaPPP3BBB2754MCDLALIO7DXKNA-I7DSS2EP2GL1AY

Table: Connections and Functionality

ATmega32 PinMAX7221 PinFunction
PB7 (SCK)CLKSerial Clock
PB5 (MOSI)DINData Input
PB4 (SS)LOADChip Select
  • SPI Mode: Master mode, MSB first
  • Initialization: Set decode mode, intensity, scan limit
  • Data Transfer: Send address byte followed by data byte
  • Multiplexing: Can drive up to 8 digits
  • Brightness Control: 16 levels through intensity register

Mnemonic: “Send Clock Data Load Display”

Question 4(a OR) [3 marks]
#

Explain MAX232 line driver.

Answer:

MAX232 is an IC that converts TTL/CMOS logic levels to RS-232 voltage levels for serial communication.

Diagram:

TRM11AIOXNU2T32CC12++CC12--RTRS112OI3UN2T|---+
  • Voltage Conversion: TTL (0/5V) to RS-232 (±12V)
  • Charge Pumps: Uses capacitors to generate required voltages
  • Applications: Serial communication with PC, modems
  • Bidirectional: Handles both transmit and receive signals

Mnemonic: “TTL To RS-232 Conversion”

Question 4(b OR) [4 marks]
#

Explain ADMUX register.

Answer:

ADC Multiplexer Selection Register (ADMUX) controls analog input channel selection and result format.

Diagram:

REF7S1REF6S0ADL5AR4MUX33MUX22MUX11MUX00

Table: ADMUX Bit Functions

BitsNameFunction
7:6REFS1:0Reference Selection
5ADLARADC Left Adjust Result
3:0MUX3:0Analog Channel Selection
  • REFS1:0: Select voltage reference (AREF, AVCC, Internal)
  • ADLAR: Result alignment in ADC registers
  • MUX3:0: Select input channel (ADC0-ADC7)

Mnemonic: “Reference, Alignment, Multiplexer”

Question 4(c OR) [7 marks]
#

Discuss Two Wire serial Interface (TWI) in AVR.

Answer:

Two Wire Interface (TWI) is AVR’s implementation of I²C protocol for communication with peripheral devices.

Diagram:

graph LR
    A[Master AVR] -- SDA --- B[Slave 1]
    A -- SCL --- B
    B -- SDA --- C[Slave 2]
    B -- SCL --- C

Table: TWI Characteristics

FeatureDescription
PinsSCL (Serial Clock) and SDA (Serial Data)
SpeedStandard (100kHz), Fast (400kHz)
Addressing7-bit or 10-bit device addressing
OperationMaster or Slave mode
Bus StructureMulti-master, multi-slave
  • Bidirectional: Both devices can transmit and receive
  • Registers: TWBR, TWCR, TWSR, TWDR, TWAR
  • ACK/NACK: Acknowledgment for reliable transfers
  • Start/Stop: Special conditions to begin/end transmission
  • Common Uses: EEPROM, RTC, sensors, displays

Mnemonic: “Serial Clock And Data Transfers”

Question 5(a) [3 marks]
#

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

Answer:

L293D provides bidirectional drive current for controlling DC motors with microcontrollers.

Circuit Diagram:

ATmegaPP3DD201IIOONNUUPL12TTo212w9e3+rD5VDCMotor
  • Control Pins: PD0, PD1 control motor direction
  • Driver Power: Separate for logic and motor
  • H-Bridge: Enables forward/reverse operation
  • Enable Pin: Can be used for PWM speed control

Mnemonic: “Direction Control Through Bridge”

Question 5(b) [4 marks]
#

Write features of on chip ADC in ATmega32.

Answer:

ATmega32 features a versatile analog-to-digital converter for measuring analog signals.

Table: ATmega32 ADC Features

FeatureSpecification
Resolution10-bit
Channels8 single-ended inputs
Conversion Time65-260 μs
Reference VoltageAREF, AVCC, or 2.56V internal
Accuracy±2 LSB
Conversion ModesSingle and Free Running
Input Range0V to VREF
  • Successive Approximation: Conversion technique
  • Multiplexer: Selects among 8 input channels
  • Interrupt: Optional interrupt on completion
  • Sampling Rate: Up to 15 KSPS at maximum resolution

Mnemonic: “Multiple Channels, Ten-bit Resolution”

Question 5(c) [7 marks]
#

Explain Smart Irrigation System.

Answer:

Smart Irrigation System automates watering based on environmental conditions using microcontroller technology.

Diagram:

graph TD
    A[ATmega32] --> B[Soil Moisture Sensor]
    A --> C[Temperature Sensor]
    A --> D[Humidity Sensor]
    A --> E[Water Pump Control]
    A --> F[Valve Control]
    A --> G[LCD Display]
    H[RTC Module] --> A

Table: System Components

ComponentFunction
Soil Moisture SensorMeasures water content in soil
Temperature/HumidityMonitors environmental conditions
Water PumpDelivers water when needed
ValvesControls water flow to different zones
LCD DisplayShows system status
RTC ModuleTracks time for scheduled irrigation
  • Adaptive Control: Adjusts watering based on conditions
  • Water Conservation: Uses only necessary amount of water
  • Remote Monitoring: Optional WiFi/GSM connectivity
  • Data Logging: Records moisture levels and watering events
  • Battery Backup: Ensures operation during power outages

Mnemonic: “Sense Moisture, Control Water Automatically”

Question 5(a OR) [3 marks]
#

Draw and explain pin diagram of L293D motor driver IC.

Answer:

L293D is a quadruple half-H driver IC used for controlling motors and other inductive loads.

Diagram:

OOEIUGGUIVNNTNNTNC111DD22C-------2-|1L29136D-------VIOGGOI-CNUNNUNEC4TDDT3N1432
  • VCC1 (Pin 16): Logic supply voltage (5V)
  • VCC2 (Pin 8): Motor supply voltage (4.5V-36V)
  • EN1/EN2: Enable inputs (can be PWM for speed control)
  • IN1-IN4: Logic inputs to control direction
  • OUT1-OUT4: Outputs to connect motors
  • GND: Ground connections

Mnemonic: “Enable, Input, Output, Power”

Question 5(b OR) [4 marks]
#

List registers associated with ADC in AVR.

Answer:

AVR’s ADC system uses several registers to control its operation and store results.

Table: ADC Registers

RegisterFunctionDescription
ADMUXMultiplexerChannel selection and reference options
ADCSRAControl & StatusControl bits and flags
ADCHData HighHigh byte of conversion result
ADCLData LowLow byte of conversion result
SFIORSpecial FunctionADC trigger source selection
  • ADMUX: Channel and reference selection
  • ADCSRA: Enable ADC, start conversion, prescaler
  • ADCH/ADCL: Result registers (10-bit value)
  • SFIOR: Auto-trigger sources (Timer, External)

Mnemonic: “Multiplexer Controls And Delivers Results”

Question 5(c OR) [7 marks]
#

Explain IoT based home automation system.

Answer:

IoT home automation connects household devices to the internet for remote monitoring and control.

Diagram:

graph TD
    A[Internet] --- B[WiFi Gateway]
    B --- C[AVR Controller]
    C --- D[Light Control]
    C --- E[Fan Control]
    C --- F[Door Lock]
    C --- G[Temperature Sensors]
    C --- H[Motion Sensors]
    B --- I[Mobile App]
    B --- J[Cloud Services]

Table: System Components

ComponentFunction
ControllerProcesses sensor data and commands
SensorsMonitor environmental conditions
ActuatorsControl appliances and systems
CommunicationWiFi/Ethernet/Bluetooth connectivity
GatewayConnects local network to internet
Mobile AppUser interface for remote control
  • Remote Access: Control home from anywhere
  • Scheduling: Automate device operation based on time
  • Voice Control: Integration with digital assistants
  • Energy Monitoring: Track power consumption
  • Security: Alerts for unusual activities
  • Scene Setting: One-touch control of multiple devices

Mnemonic: “Connect, Control, Automate, Monitor”

Related

Consumer Electronics & Maintenance (4341107) - Summer 2024 Solution
15 mins
Study-Material Solutions Consumer-Electronics 4341107 2024 Summer
Electronics Devices & Circuits (1323202) - Summer 2024 Solution
13 mins
Study-Material Solutions Electronics 1323202 2024 Summer
Digital Electronics (4321102) - Summer 2024 Solution
16 mins
Study-Material Solutions Digital-Electronics 4321102 2024 Summer
Antenna & Wave Propagation (4341106) - Summer 2024 Solution
20 mins
Study-Material Solutions Antenna Wave-Propagation 4341106 2024 Summer
Electronic Circuits & Applications (4321103) - Summer 2024 Solution
18 mins
Study-Material Solutions Electronic-Circuits 4321103 2024 Summer
Python Programming (1323203) - Summer 2024 Solution
19 mins
Study-Material Solutions Python 1323203 2024 Summer