Skip to main content
  1. Resources/
  2. Study Materials/
  3. Electronics & Communication Engineering/
  4. ECE Semester 5/

Embedded System & Microcontroller Application (4351102) - Winter 2023 Solution

14 mins· ·
Study-Material Solutions Embedded-System 4351102 2023 Winter
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

Question 1(a) [3 marks]
#

Draw TIFR register and write its full name.

Answer:

TIFR Register Diagram:

O7CF2|6TOV25|ICF41|OC3F1A|2OCF11B|TO0V1OCF0|TOV0|

Full Name: Timer/Counter Interrupt Flag Register

  • TOV0: Timer0 Overflow Flag
  • OCF0: Timer0 Output Compare Flag
  • TOV1: Timer1 Overflow Flag

Mnemonic: “Timer Interrupts Flag Register”

Question 1(b) [4 marks]
#

Discuss data memory of ATmega32.

Answer:

Memory TypeSizeAddress RangePurpose
General Purpose Registers32 bytes0x00-0x1FR0-R31 registers
I/O Memory64 bytes0x20-0x5FControl registers
Internal SRAM2048 bytes0x60-0x85FVariable storage
  • General Purpose Registers: Used for arithmetic operations and temporary storage
  • I/O Memory: Contains peripheral control and status registers
  • Internal SRAM: Used for stack, variables, and dynamic memory allocation

Mnemonic: “General I/O SRAM Memory”

Question 1(c) [7 marks]
#

Draw and explain general block diagram of embedded system.

Answer:

graph TD
    A[Input Devices] --> B[Processor/Microcontroller]
    B --> C[Memory]
    B --> D[Output Devices]
    B --> E[Communication Interface]
    F[Power Supply] --> B
    G[Clock Circuit] --> B
ComponentFunction
ProcessorControls entire system operation
MemoryStores program and data
Input DevicesSensors, switches, keyboards
Output DevicesLEDs, displays, motors
CommunicationUART, SPI, I2C interfaces
  • Real-time Operation: System responds to inputs within defined time limits
  • Dedicated Function: Designed for specific applications
  • Resource Constraints: Limited memory, power, and processing capability

Mnemonic: “Processor Memory Input Output Communication”

Question 1(c OR) [7 marks]
#

Define real time operating system and explain its characteristics.

Answer:

Definition: Real Time Operating System (RTOS) is an operating system that guarantees response within specified time constraints for critical tasks.

CharacteristicDescription
DeterministicPredictable response times
MultitaskingMultiple tasks execution
Priority-basedHigh priority tasks first
Minimal LatencyFast interrupt response
  • Hard Real-time: Missing deadline causes system failure
  • Soft Real-time: Performance degrades if deadline missed
  • Task Scheduling: Preemptive priority-based scheduling ensures critical tasks run first

Mnemonic: “Deterministic Multitasking Priority Minimal”

Question 2(a) [3 marks]
#

Write Criteria for choosing microcontroller for embedded system.

Answer:

CriteriaImportance
Processing SpeedMatch application requirements
Memory SizeSufficient ROM/RAM
I/O PinsAdequate peripheral interfaces
Power ConsumptionBattery life consideration
CostBudget constraints
Development ToolsCompiler, debugger availability

Mnemonic: “Speed Memory I/O Power Cost Tools”

Question 2(b) [4 marks]
#

Discuss Harvard Architecture in the AVR.

Answer:

Harvard Architecture Features:

FeatureDescription
Separate BusesProgram and data have independent buses
Simultaneous AccessCan fetch instruction and access data simultaneously
Different Memory TypesFlash for program, SRAM for data
graph LR
    A[CPU] --> B[Program Memory Bus]
    A --> C[Data Memory Bus]
    B --> D[Flash Memory]
    C --> E[SRAM]
  • Advantage: Higher performance due to parallel access
  • 16-bit Instructions: Most instructions execute in single clock cycle

Mnemonic: “Separate Simultaneous Different Performance”

Question 2(c) [7 marks]
#

Discuss different ways of connecting clock sources to the AVR.

Answer:

Clock SourceFrequency RangeApplication
External Crystal1-16 MHzHigh accuracy applications
External RC1-8 MHzCost-effective solution
Internal RC1-8 MHzDefault, no external components
External ClockUp to 16 MHzSynchronized systems

Clock Selection via Fuse Bits:

CCSKKUSDTEI1LV:380:0bbiibttistdsisveditedtesestramcriltnouecpkctlbioymcek8source
  • Crystal Oscillator: Most stable, requires external crystal and capacitors
  • RC Oscillator: Less accurate but cheaper
  • Internal Oscillator: Factory calibrated, temperature dependent

Mnemonic: “Crystal RC Internal External”

Question 2(a OR) [3 marks]
#

Write size of code ROM, SRAM and EEPROM, Number of I/O pins, ADC and Timers for ATmega32.

Answer:

SpecificationATmega32
Flash ROM32 KB
SRAM2 KB
EEPROM1 KB
I/O Pins32 pins
ADC Channels8 channels
Timers3 timers

Mnemonic: “32K Flash 2K SRAM 1K EEPROM 32 I/O 8 ADC 3 Timers”

Question 2(b OR) [4 marks]
#

Draw ATmega32 pin diagram and write function of Vcc, AVcc and Aref pin.

Answer:

Pin Functions:

PinFunction
VccMain power supply (+5V)
AVccAnalog power supply for ADC
ArefADC reference voltage
VAcrce-f132ATmega322400|--GANVDcc
  • Vcc: Supplies power to digital circuits
  • AVcc: Separate supply for ADC to reduce noise
  • Aref: External reference for ADC conversion

Mnemonic: “Vcc Digital AVcc Analog Aref Reference”

Question 2(c OR) [7 marks]
#

Explain AVR status register in detail.

Answer:

SREG (Status Register) Bits:

BitNameFunction
7IGlobal Interrupt Enable
6TBit Copy Storage
5HHalf Carry Flag
4SSign Flag
3VOverflow Flag
2NNegative Flag
1ZZero Flag
0CCarry Flag
I7T6H5S4V3N2Z1C0
  • I Flag: Controls global interrupt enable/disable
  • Arithmetic Flags: C, Z, N, V, S, H updated after ALU operations
  • T Flag: Used by BLD and BST instructions for bit manipulation

Mnemonic: “I Transfer Half Sign oVerflow Negative Zero Carry”

Question 3(a) [3 marks]
#

Explain RESET circuit for the AVR microcontroller.

Answer:

Reset Sources:

Reset SourceDescription
Power-on ResetWhen power is applied
External ResetThrough RESET pin
Brown-out ResetWhen voltage drops
Watchdog ResetWatchdog timer overflow
Vcc-[R]----GCNDRESETpin
  • Reset Duration: Minimum 2 clock cycles
  • Reset Vector: Program starts from address 0x0000

Mnemonic: “Power External Brown-out Watchdog”

Question 3(b) [4 marks]
#

List I/O registers associated with EEPROM. Write programming steps to write data on EEPROM.

Answer:

EEPROM Registers:

RegisterFunction
EEAREEPROM Address Register
EEDREEPROM Data Register
EECREEPROM Control Register

Programming Steps:

  1. Wait for previous write to complete (check EEWE bit)
  2. Set address in EEAR register
  3. Set data in EEDR register
  4. Set EEMWE bit in EECR
  5. Set EEWE bit within 4 clock cycles

Mnemonic: “Wait Address Data Master-Write Enable-Write”

Question 3(c) [7 marks]
#

Draw and explain TCCR0 register in detail.

Answer:

TCCR0 (Timer/Counter0 Control Register):

BitNameFunction
7FOC0Force Output Compare
6,3WGM01,WGM00Waveform Generation Mode
5,4COM01,COM00Compare Output Mode
2,1,0CS02,CS01,CS00Clock Select
FO7C0WG6M01CO5M01CO4M00WG3M00CS202CS101CS000

Clock Select Options:

  • 000: No clock (Timer stopped)
  • 001: clk/1 (No prescaling)
  • 010: clk/8, 011: clk/64
  • 100: clk/256, 101: clk/1024

Mnemonic: “Force Waveform Compare Clock Select”

Question 3(a OR) [3 marks]
#

List registers associated with Timer 1.

Answer:

Timer1 Registers:

RegisterFunction
TCCR1ATimer1 Control Register A
TCCR1BTimer1 Control Register B
TCNT1H/LTimer1 Counter Register
OCR1AH/LOutput Compare Register A
OCR1BH/LOutput Compare Register B
ICR1H/LInput Capture Register

Mnemonic: “Control Counter Output-Compare Input-Capture”

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>

void eeprom_write_byte_custom(uint16_t addr, uint8_t data)
{
    while(EECR & (1<<EEWE));  // Wait for previous write
    EEAR = addr;              // Set address
    EEDR = data;              // Set data
    EECR |= (1<<EEMWE);       // Master write enable
    EECR |= (1<<EEWE);        // Write enable
}

int main()
{
    eeprom_write_byte_custom(0x005F, 'G');
    return 0;
}

Program Steps:

  • Check EEWE bit for completion
  • Load address 0x005F into EEAR
  • Load ‘G’ (ASCII 71) into EEDR
  • Enable master write, then write enable

Mnemonic: “Wait Address Data Master Write”

Question 3(c OR) [7 marks]
#

Write a C program to toggle only the PORTB.4 bit continuously every 70 μs. Use Timer0, Normal mode, and 1:8 prescaler to create the delay. Assume XTAL = 8 MHz.

Answer:

#include <avr/io.h>

int main()
{
    DDRB |= (1<<4);           // Set PB4 as output
    TCCR0 = 0x02;             // Prescaler 1:8
    
    while(1)
    {
        TCNT0 = 186;          // Load initial value
        while(!(TIFR & (1<<TOV0))); // Wait for overflow
        TIFR |= (1<<TOV0);    // Clear flag
        PORTB ^= (1<<4);      // Toggle PB4
    }
    return 0;
}

Calculation:

  • Clock = 8MHz/8 = 1MHz
  • For 70μs: Count = 70 cycles
  • Initial value = 256-70 = 186

Mnemonic: “Direction Control Count Wait Clear Toggle”

Question 4(a) [3 marks]
#

Write an AVR C program to monitor bit 5 of port C. If it is HIGH, send 55H to Port B; otherwise, send AAH to Port B.

Answer:

#include <avr/io.h>

int main()
{
    DDRC &= ~(1<<5);          // PC5 as input
    DDRB = 0xFF;              // Port B as output
    
    while(1)
    {
        if(PINC & (1<<5))     // Check PC5
            PORTB = 0x55;     // Send 55H if HIGH
        else
            PORTB = 0xAA;     // Send AAH if LOW
    }
    return 0;
}

Program Logic:

  • Configure PC5 as input, Port B as output
  • Continuously check PC5 status
  • Output 0x55 or 0xAA based on input

Mnemonic: “Direction Check Output”

Question 4(b) [4 marks]
#

Draw and explain interfacing of LM35 with ATmega32.

Answer:

graph LR
    A[LM35] --> B[PA0/ADC0]
    B --> C[ATmega32]
    D[+5V] --> A
    E[GND] --> A

Connection Table:

LM35 PinATmega32 PinFunction
Vcc+5VPower supply
OutputPA0 (ADC0)Analog voltage
GNDGNDGround
  • Temperature Conversion: 10mV/°C output
  • ADC Resolution: 10-bit (0-1023)
  • Voltage Range: 0V to 5V (0°C to 500°C)

Mnemonic: “Power Output Ground Temperature”

Question 4(c) [7 marks]
#

Draw and explain interfacing of MAX7221 with ATmega32.

Answer:

graph LR
    A[ATmega32] --> B[MAX7221]
    A --> C[7-Segment Display]
    B --> C

Connection Table:

MAX7221 PinATmega32 PinFunction
DINMOSI (PB5)Serial data input
CLKSCK (PB7)Serial clock
LOADSS (PB4)Chip select

Features:

  • SPI Interface: Serial communication protocol
  • 8-Digit Display: Controls up to 8 seven-segment displays
  • Built-in Decoder: BCD to seven-segment conversion
  • Brightness Control: 16 intensity levels

Programming Steps:

  1. Initialize SPI in master mode
  2. Send address and data bytes
  3. Pulse LOAD signal to latch data

Mnemonic: “Serial Clock Load Display”

Question 4(a OR) [3 marks]
#

Write an AVR C program to get a byte of data from Port B, and then send it to Port C.

Answer:

#include <avr/io.h>

int main()
{
    DDRB = 0x00;              // Port B as input
    DDRC = 0xFF;              // Port C as output
    
    uint8_t data;
    
    while(1)
    {
        data = PINB;          // Read from Port B
        PORTC = data;         // Send to Port C
    }
    return 0;
}

Program Function:

  • Configure Port B as input, Port C as output
  • Continuously read from PINB and write to PORTC

Mnemonic: “Input Output Read Write”

Question 4(b OR) [4 marks]
#

Draw and explain interfacing of ULN2803 with ATmega32.

Answer:

graph TD
    A[ATmega32 Port] --> B[ULN2803 Input]
    B --> C[ULN2803 Output]
    C --> D[Load/Relay]
    E[Vcc] --> D

ULN2803 Features:

FeatureDescription
8 Darlington ArraysHigh current switching
Input Current500μA typical
Output Current500mA per channel
Built-in Flyback DiodesInductive load protection
  • Application: Drive relays, motors, solenoids
  • Voltage Drop: 1.2V typical across Darlington pair
  • Active Low Output: Output goes low when input is high

Mnemonic: “Darlington Current Protection Drive”

Question 4(c OR) [7 marks]
#

Discuss registers used to program SPI in the AVR.

Answer:

SPI Registers:

RegisterBitsFunction
SPCRSPE, DORD, MSTR, CPOLSPI Control Register
SPSRSPIF, WCOL, SPI2XSPI Status Register
SPDR-SPI Data Register

SPCR Register Bits:

  • SPE: SPI Enable
  • DORD: Data Order (MSB/LSB first)
  • MSTR: Master/Slave Select
  • CPOL: Clock Polarity
  • CPHA: Clock Phase

SPSR Register Bits:

  • SPIF: SPI Interrupt Flag
  • WCOL: Write Collision Flag
  • SPI2X: Double Speed Mode

Programming Sequence:

  1. Configure SPI pins as input/output
  2. Set SPCR register for desired mode
  3. Write data to SPDR
  4. Wait for SPIF flag
  5. Read received data from SPDR

Mnemonic: “Control Status Data Enable Order Master”

Question 5(a) [3 marks]
#

Draw and explain pin diagram of L293D motor driver IC.

Answer:

111GG22VEAYNNYAcN--DD--c-------212345678L293D111111165432109--------V44GG332cAYNNYAEcDDN1

Pin Functions:

PinFunction
1A, 2AInput signals for Motor 1
3A, 4AInput signals for Motor 2
1Y, 2YOutput to Motor 1
3Y, 4YOutput to Motor 2
1EN, 2ENEnable pins for motors
Vcc1Logic supply (+5V)
Vcc2Motor supply (+12V)

Mnemonic: “Input Output Enable Logic Motor Supply”

Question 5(b) [4 marks]
#

Draw and explain ADMUX register.

Answer:

ADMUX (ADC Multiplexer Selection Register):

BitNameFunction
7,6REFS1,REFS0Reference Selection
5ADLARADC Left Adjust Result
4-0MUX4-MUX0Analog Channel Selection
REF7S1REF6S0ADL5ARMU4X4MU3X3MU2X2MU1X1MU0X0

Reference Selection:

  • 00: AREF pin
  • 01: AVcc with external capacitor
  • 11: Internal 2.56V reference

Channel Selection: MUX bits select ADC0-ADC7 channels

Mnemonic: “Reference Adjust Multiplexer Channel”

Question 5(c) [7 marks]
#

Explain GSM based security system.

Answer:

graph TD
    A[Sensors] --> B[Microcontroller]
    B --> C[GSM Module]
    C --> D[Mobile Network]
    D --> E[User Mobile]
    F[Keypad] --> B
    G[Display] --> B

System Components:

ComponentFunction
PIR SensorMotion detection
Door SensorEntry detection
GSM ModuleSMS/Call communication
MicrocontrollerSystem control
KeypadUser interface
DisplayStatus indication

Working Principle:

  1. Sensors detect intrusion
  2. Microcontroller processes signal
  3. GSM module sends SMS alert
  4. User receives notification
  5. System can be armed/disarmed remotely

Features:

  • Remote Monitoring: SMS notifications
  • Multiple Sensors: PIR, door, window sensors
  • User Interface: LCD display and keypad
  • Emergency Response: Automatic alert system

Mnemonic: “Sensors Process Communicate Alert Control”

Question 5(a OR) [3 marks]
#

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

Answer:

APPPTAAAm012eG++gN51aDV23V2121LAAE2((NGVV927Ncc3))1DccD)(124((,1856),)12,1123YY)((D36C))MotorMMoottoorr+-

Connection Table:

ATmega32L293DFunction
PA01A (Pin 2)Direction control 1
PA12A (Pin 7)Direction control 2
PA21EN (Pin 1)Motor enable

Motor Control:

  • PA0=1, PA1=0: Clockwise rotation
  • PA0=0, PA1=1: Counter-clockwise rotation
  • PA2=0: Motor stop

Mnemonic: “Direction Enable Control Stop”

Question 5(b OR) [4 marks]
#

Draw and explain ADCSRA register.

Answer:

ADCSRA (ADC Control and Status Register A):

BitNameFunction
7ADENADC Enable
6ADSCADC Start Conversion
5ADATEADC Auto Trigger Enable
4ADIFADC Interrupt Flag
3ADIEADC Interrupt Enable
2-0ADPS2-ADPS0ADC Prescaler Select
AD7ENAD6SCAD5ATEAD4IFAD3IEAD2PS2AD1PS1AD0PS0

Prescaler Selection:

  • 000: Division factor 2
  • 001: Division factor 2
  • 010: Division factor 4
  • 011: Division factor 8

ADC Operation Steps:

  1. Set ADEN to enable ADC
  2. Set ADSC to start conversion
  3. Wait for ADIF flag
  4. Read result from ADCH:ADCL

Mnemonic: “Enable Start Auto Interrupt Prescaler”

Question 5(c OR) [7 marks]
#

Explain Weather monitoring system.

Answer:

graph TD
    A[Temperature Sensor] --> E[Microcontroller]
    B[Humidity Sensor] --> E
    C[Pressure Sensor] --> E
    D[Rain Sensor] --> E
    E --> F[Display]
    E --> G[Data Logger]
    E --> H[Wireless Module]
    H --> I[Remote Monitor]

System Components:

SensorParameterInterface
LM35TemperatureAnalog (ADC)
DHT11HumidityDigital
BMP180PressureI2C
Rain SensorPrecipitationDigital

Features:

  • Multi-parameter Monitoring: Temperature, humidity, pressure, rainfall
  • Data Logging: Store readings in EEPROM/SD card
  • Real-time Display: LCD shows current readings
  • Wireless Communication: WiFi/GSM for remote monitoring
  • Alert System: Threshold-based warnings

Applications:

  • Agricultural monitoring
  • Weather forecasting
  • Environmental research
  • Smart home automation

System Benefits:

  • Automated Data Collection: Continuous monitoring
  • Remote Access: View data from anywhere
  • Historical Analysis: Trend identification
  • Early Warning: Extreme weather alerts

Mnemonic: “Temperature Humidity Pressure Rain Display Log Wireless”

Related

Electronic Circuits & Applications (4321103) - Winter 2023 Solution
16 mins
Study-Material Solutions Electronics 4321103 2023 Winter
Principles of Electronic Communication (4331104) - Winter 2023 Solution
20 mins
Study-Material Solutions Electronic-Communication 4331104 2023 Winter
Fundamentals of Electrical Engineering (4311101) - Winter 2023 Solution
12 mins
Study-Material Solutions Electrical-Engineering 4311101 2023 Winter
Digital Electronics (4321102) - Winter 2023 Solution
15 mins
Study-Material Solutions Digital-Electronics 4321102 2023 Winter
Electronic Circuits & Networks (4331101) - Winter 2023 Solution
15 mins
Study-Material Solutions Electronic-Circuits Networks 4331101 2023 Winter
Electronic Circuits & Applications (4321103) - Summer 2023 Solution
19 mins
Study-Material Solutions Electronic-Circuits 4321103 2023 Summer