Quiz Space

January 2025 term · Embedded C Programming · CS2101

Embedded C Programming End Term: 13 April 2025, Set QEF3 (January 2025 term)

The IIT Madras BS Embedded C Programming (Embedded C Programming) End Term paper sat on 13 Apr 2025, in the January 2025 term, set QEF3: 21 questions for 52 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
21
Marks
52
Duration
180 min
MCQ
20
Numerical
1

Updated

Official paper: IIT M ES FOUNDATION AN EXAM QEF3 13 Apr 2025 · No negative marking.

Question 1

+4 marksOne correct option

Consider the following FreeRTOS code snippet:

c
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
QueueHandle_t xQueue;
void SenderTask(void *pvParameters) {
int data = 100;
while (1) {
if (xQueueSend(xQueue, &data, pdMS_TO_TICKS(1000)) == pdPASS) {
printf("Data sent: %d\n", data);
}
vTaskDelay(pdMS_TO_TICKS(500));
}
}
void ReceiverTask(void *pvParameters) {
int receivedData;
while (1) {
if (xQueueReceive(xQueue, &receivedData, pdMS_TO_TICKS(2000)) == pdTRUE) {
printf("Data received: %d\n", receivedData);
}
}
}
int main() {
xQueue = xQueueCreate(5, sizeof(int));
xTaskCreate(SenderTask, "Sender", 1000, NULL, 1, NULL);
xTaskCreate(ReceiverTask, "Receiver", 1000, NULL, 1, NULL);
vTaskStartScheduler();
while (1);
}

What will happen if the receiver task is delayed for more than 3 seconds?

  1. A

    The sender task will be blocked permanently

  2. B

    The queue will eventually be full, and the sender task will be blocked until space is available

  3. C

    The queue will clear automatically, allowing the sender to continue

  4. D

    The system will crash due to queue overflow

Show answer

Correct answer

  • B

    The queue will eventually be full, and the sender task will be blocked until space is available

Question 2

+4 marksOne correct option

Consider a finite state machine (FSM) controlling a motor speed system with a single button. The states and events are defined as follows:

States:

  1. STATE_STOPPED – Motor is off.
  2. STATE_SLOW – Motor runs at slow speed.
  3. STATE_FAST – Motor runs at fast speed.
  4. STATE_OVERSPEED – Motor runs at an unsafe speed.

Events:

  1. EVENT_BUTTON_PRESS – Button is pressed.
  2. EVENT_SENSOR_ALERT – A sensor detects overspeed.

Consider the following code.

c
void handleEvent(Event_t event) {
switch (currentState) {
case STATE_STOPPED:
if (event == EVENT_BUTTON_PRESS) {
currentState = STATE_SLOW;
}
break;
case STATE_SLOW:
if (event == EVENT_BUTTON_PRESS) {
currentState = STATE_FAST;
}
break;
case STATE_FAST:
if (event == EVENT_BUTTON_PRESS) {
currentState = STATE_STOPPED;
} else if (event == EVENT_SENSOR_ALERT) {
currentState = STATE_OVERSPEED;
}
break;
case STATE_OVERSPEED:
if (event == EVENT_BUTTON_PRESS) {
currentState = STATE_STOPPED;
}
break;
default:
currentState = STATE_STOPPED;
break;
}
}

If the initial state is STATE_SLOW, what will be the next state after one EVENT_BUTTON_PRESS and one EVENT_SENSOR_ALERT event?

  1. A

    STATE_STOPPED

  2. B

    STATE_FAST

  3. C

    STATE_OVERSPEED

  4. D

    STATE_SLOW

Show answer

Correct answer

  • C

    STATE_OVERSPEED

Question 3

+2 marksOne correct option

What is the main issue caused by priority inversion in an RTOS?

  1. A

    High-priority tasks being blocked by low-priority tasks holding a shared resource

  2. B

    Low-priority tasks consuming all CPU time

  3. C

    Tasks executing in an unpredictable order

  4. D

    RTOS scheduler failing to schedule tasks correctly

Show answer

Correct answer

  • A

    High-priority tasks being blocked by low-priority tasks holding a shared resource

Question 4

+2 marksOne correct option

What is the main advantage of using timers in an RTOS?

  1. A

    Allows periodic execution of tasks without busy-waiting

  2. B

    Increases CPU utilization by running tasks continuously

  3. C

    Prevents task preemption in a multitasking environment

  4. D

    Eliminates the need for task scheduling

Show answer

Correct answer

  • A

    Allows periodic execution of tasks without busy-waiting

Question 5

+2 marksOne correct option

What is the primary purpose of the vTaskDelay() function in FreeRTOS?

  1. A

    Suspends the task indefinitely until manually resumed.

  2. B

    Puts the task in a blocked state for a specified time without using CPU cycles.

  3. C

    Lowers the task priority and reschedules it after a delay.

  4. D

    Immediately stops the task and frees its resources.

Show answer

Correct answer

  • B

    Puts the task in a blocked state for a specified time without using CPU cycles.

Question 6

+2 marksOne correct option

In which situation should an interrupt be used instead of polling?

  1. A

    Monitoring a push button for user input

  2. B

    Checking a sensor value every 5 seconds

  3. C

    Updating system logs every minute

  4. D

    Sending periodic status updates over UART

Show answer

Correct answer

  • A

    Monitoring a push button for user input

Question 7

+2 marksOne correct option

Which of the following is considered the best practice for optimizing memory usage in an embedded system?

  1. A

    Using dynamic memory allocation extensively

  2. B

    Minimizing the use of global variables and using stack-based allocation

  3. C

    Keeping all variables in global memory for quick access

  4. D

    Increasing the heap size to accommodate more dynamic allocations

Show answer

Correct answer

  • B

    Minimizing the use of global variables and using stack-based allocation

Question 8

+2 marksOne correct option

Which of the following statements best describes the purpose of unit testing in software development?

  1. A

    Unit testing ensures that all the components of a software system work together as intended.

  2. B

    Unit testing involves testing the entire software system to ensure it meets the end user's requirements.

  3. C

    Unit testing is a method used to test hardware components in an embedded system.

  4. D

    Unit testing focuses on verifying the correct behavior of individual units of code, such as functions, in isolation from the rest of the system.

Show answer

Correct answer

  • D

    Unit testing focuses on verifying the correct behavior of individual units of code, such as functions, in isolation from the rest of the system.

Question 9

+2 marksOne correct option

What are the final values of AX, BX, and CX registers after executing the following assembly code. MOV AX, 70
MOV BX, 95
ADD AX, BX
MOV CX, AX
MOV DX, 40
SUB BX, DX

  1. A

    AX = 165, BX = 55, CX = 155

  2. B

    AX = 165, BX = 50, CX = 155

  3. C

    AX = 160, BX = 55, CX = 150

  4. D

    AX = 155, BX = 55, CX = 150

Show answer

Correct answer

  • A

    AX = 165, BX = 55, CX = 155

Question 10

+2 marksOne correct option

A microcontroller is running a main program that continuously updates a sensor value. An external interrupt is triggered to handle a button press. Why must the ISR save and restore the context before returning to the main program?

  1. A

    To prevent the button press from being registered multiple times

  2. B

    To ensure the sensor update process resumes correctly after the ISR execution

  3. C

    To reduce the power consumption of the microcontroller

  4. D

    To allow the ISR to execute faster without delays

Show answer

Correct answer

  • B

    To ensure the sensor update process resumes correctly after the ISR execution

Question 11

+2 marksOne correct option

You are designing a system where a microcontroller needs to interface with multiple accelerometers for motion tracking. Which communication protocol would be more suitable and why?

  1. A

    I2C, because it allows multiple devices to be connected using only two wires

  2. B

    SPI, because it provides faster data transfer and supports multiple devices using chip select lines

  3. C

    I2C, because it supports full-duplex communication for high-speed data transfer

  4. D

    SPI, because it requires fewer connections than I2C for multiple devices

Show answer

Correct answer

  • A

    I2C, because it allows multiple devices to be connected using only two wires

Question 12

+2 marksOne correct option

A CPU has 512KB of SRAM connected to it, starting at address 0x00800000. What is the address of the last byte in the SRAM?

  1. A

    0x0087FFFF

  2. B

    0x008FFFFF

  3. C

    0x00880000

  4. D

    0x0087FFFE

Show answer

Correct answer

  • A

    0x0087FFFF

Question 13

+2 marksOne correct option

You are designing an embedded system that stores sensor readings in an array. The sensor values range from 0 to 200. To optimize memory usage, which data type should you choose for storing these values?

  1. A

    int

  2. B

    unsigned int

  3. C

    uint16_t

  4. D

    uint8_t

Show answer

Correct answer

  • D

    uint8_t

Question 14

+2 marksOne correct option

What is the result of 0xB4 >> 2?

  1. A

    0x2D

  2. B

    0x1B

  3. C

    0x16

  4. D

    0x2E

Show answer

Correct answer

  • A

    0x2D

Question 15

+3 marksOne correct option

A microcontroller needs to play a high-quality audio file by sending data to an I2S-based audio codec. The audio buffer in memory holds 16-bit PCM data at a sampling rate of 44.1 kHz. What is the best method to ensure smooth audio playback without CPU overload?

  1. A

    The CPU loads and sends each audio sample to the I2S peripheral manually.

  2. B

    Use an interrupt to transfer data each time the I2S buffer is empty.

  3. C

    Set up DMA to transfer audio data from memory to the I2S peripheral automatically.

  4. D

    Use a while loop to continuously send data to the I2S interface.

Show answer

Correct answer

  • C

    Set up DMA to transfer audio data from memory to the I2S peripheral automatically.

Question 16

+3 marksOne correct option

You are developing an image processing application that applies filters to high-resolution images. After releasing the first version, you notice that the application takes a long time to process multiple images. You use a profi ling tool and discover that the main bottleneck is the time spent loading and saving images to disk.
What is the most effective optimization to improve the application's performance?

  1. A

    Rewrite the application using a faster programming language.

  2. B

    Implement an in-memory caching system to reduce redundant disk reads and writes.

  3. C

    Increase the image resolution to improve processing accuracy.

  4. D

    Add more logging to monitor each step of the image processing pipeline.

Show answer

Correct answer

  • B

    Implement an in-memory caching system to reduce redundant disk reads and writes.

Question 17

+3 marksOne correct option

You are designing a smart home system where IoT devices communicate over a wireless network. During testing, you find that attackers can intercept and manipulate the transmitted data. What is the best way to enhance security and prevent unauthorized access?

  1. A

    Implement encryption to secure communication between devices.

  2. B

    Increase the signal strength to improve connectivity.

  3. C

    Disable authentication to reduce communication delays.

  4. D

    Use a higher-frequency wireless module for faster data transfer.

Show answer

Correct answer

  • A

    Implement encryption to secure communication between devices.

Question 18

+3 marksOne correct option

You are designing an embedded system for an industrial monitoring device that must run continuously without failure. During testing, you observe that sometimes the system becomes unresponsive due to unexpected software bugs.
which of the following can help the system recover if unexpected failures occur

  1. A

    Implement a Watchdog Timer (WDT) to reset the system if it becomes unresponsive.

  2. B

    Use a faster microcontroller to prevent the system from hanging.

  3. C

    Disable interrupts to avoid unexpected behavior.

  4. D

    Increase the system clock speed to improve performance.

Show answer

Correct answer

  • A

    Implement a Watchdog Timer (WDT) to reset the system if it becomes unresponsive.

Question 19

+3 marksOne correct option

You are designing a wireless temperature sensor for an IoT-based smart home system. The device will be battery-powered and must operate for several months without recharging. Which processing unit would be the best choice for efficiency and battery life?

  1. A

    A microprocessor (MPU) to handle complex computations for data analysis

  2. B

    A microcontroller (MCU) to optimize power consumption and extend battery life

  3. C

    A high-performance CPU to process large amounts of data quickly

  4. D

    A dedicated AI accelerator to enable advanced machine learning features on the sensor

Show answer

Correct answer

  • B

    A microcontroller (MCU) to optimize power consumption and extend battery life

Question 20

+3 marksOne correct option

A memory-mapped I/O device has a control register bank starting at address 0x40010000. Each register is 16 bits (2 bytes) wide. If there are 20 registers in the bank, what is the address of the 15th register?

  1. A

    0x4001001C

  2. B

    0x4001001E

  3. C

    0x4001001A

  4. D

    0x4001001F

Show answer

Correct answer

  • A

    0x4001001C

Question 21

+2 marksNumerical answer

A 11-bit ADC can digitize an analog value into ___ distinct levels.

Show answer

Correct answer: 2048