Embedded systems interviews for freshers in India usually test five areas: Embedded C, microcontrollers and interrupts, communication protocols (UART, SPI, I2C, CAN), RTOS concepts, and Embedded Linux basics. The questions below come up often in those rounds. Each answer is short enough to say aloud and names the bug the interviewer is really checking you understand.
Contents
Embedded C
1. What does the volatile keyword do, and when must you use it?
It tells the compiler that a variable can change outside the normal flow of the code, so every read must go back to memory instead of reusing a cached copy. Use it for memory-mapped peripheral registers, variables shared between an interrupt service routine (ISR) and the main loop, and variables modified by another thread or core. Without it, an optimising compiler can turn while (!flag) into an infinite loop.
2. What is the difference between const and volatile, and can a variable be both?
const means your code must not write to it. volatile means it can change without your code writing to it. A read-only hardware status register is both: const volatile uint32_t *STATUS = (const volatile uint32_t *)0x40021000;.
3. How do you set, clear, toggle and test a bit in a register?
Set: reg |= (1U << n); Clear: reg &= ~(1U << n); Toggle: reg ^= (1U << n); Test: if (reg & (1U << n)). Use unsigned constants (1U), because shifting a signed 1 into the sign bit is undefined behaviour.
4. What is the size of a pointer, and why does it matter in embedded code?
It depends on the architecture’s address width: 4 bytes on 32-bit ARM Cortex-M and 8 bytes on 64-bit targets. It matters when you cast pointers to integers, pack structures shared over protocols, or port code between 8-, 16-, 32- and 64-bit MCUs. Use uintptr_t and fixed-width types from <stdint.h>.
5. What is structure padding, and how do you control it?
Compilers insert padding bytes so members sit on their natural alignment boundaries, which makes sizeof(struct) larger than the sum of its members. Reordering members from largest to smallest reduces padding. __attribute__((packed)) or #pragma pack removes it, but reading packed multi-byte fields can be slow, or can fault on cores that require alignment. Never send a raw struct over a wire without defining the layout explicitly.
6. Explain little-endian vs big-endian, and write a check.
Little-endian stores the least significant byte at the lowest address (ARM in its usual configuration, x86); big-endian stores the most significant byte first (network byte order). Check: uint16_t x = 1; bool little = *(uint8_t *)&x == 1;. Protocol code must convert explicitly, for example with htons/ntohl.
7. Why is malloc often avoided in firmware?
Dynamic allocation can fragment a small heap, has non-deterministic timing, and fails in ways that are hard to test. Safety-related coding standards such as MISRA C restrict it. Firmware usually uses static allocation, fixed-size memory pools, or allocates once at start-up.
8. What goes into the .text, .data, .bss and stack sections?
.text holds code and usually constants (in flash). .data holds initialised globals: stored in flash and copied to RAM at start-up. .bss holds zero-initialised globals, cleared to zero by the start-up code. The stack holds local variables and return addresses and grows at run time. The linker script and start-up file decide where each one lives.
Microcontrollers and interrupts
9. What happens when an interrupt occurs on an ARM Cortex-M?
The core finishes or abandons the current instruction and automatically stacks R0–R3, R12, LR, PC and xPSR. It loads the handler address from the vector table and runs the ISR, and on return unstacks the saved context. The NVIC handles priorities and nesting; a higher-priority interrupt can pre-empt a lower-priority ISR.
10. What rules should an ISR follow?
Keep it short. Clear the interrupt source, capture the data, set a flag or push to a queue, and return. Avoid blocking calls, printf, floating point (unless the context is saved) and dynamic allocation. Mark shared variables volatile, and protect multi-byte shared data from races with the main loop.
11. What is the difference between a microprocessor and a microcontroller?
A microprocessor is a CPU that needs external memory and peripherals. A microcontroller integrates the CPU, flash, RAM and peripherals such as timers, ADC, UART, SPI and I2C on one chip, and is built for low cost, low power, real-time control. An SoC goes further, integrating several processors, accelerators and complex interfaces.
12. What is a watchdog timer, and how should it be fed?
A hardware timer that resets the system if the software stops refreshing it, which recovers from hangs. Feed it from the main loop only after checking that each critical task has made progress. Feeding it from a timer ISR defeats the purpose, because the ISR keeps running while the application is stuck.
13. Polling vs interrupt-driven I/O: when do you use each?
Polling is simple and predictable for fast or always-busy devices, but wastes CPU time and power. Interrupts suit infrequent or asynchronous events and low-power designs. High-throughput peripherals often combine interrupts with DMA, so data moves without the CPU touching every byte.
14. What is debouncing, and how do you implement it?
A mechanical switch bounces for a few milliseconds, producing several transitions. Debounce it in hardware (an RC filter plus a Schmitt trigger) or in software: sample the input periodically, for example every 5–10 ms, and accept a new state only after it has been stable for several consecutive samples.
Communication protocols
15. Compare UART, SPI and I2C.
UART is asynchronous, point-to-point, 2 wires (TX/RX), and both ends must agree on the baud rate. SPI is synchronous, full-duplex and fast (MHz), with 4 wires (SCLK, MOSI, MISO, CS) and one chip-select per slave. I2C is synchronous, half-duplex, 2 wires (SDA, SCL) with pull-ups, supports multiple masters and slaves through 7- or 10-bit addressing and ACK/NACK, and runs slower (typically 100 kHz / 400 kHz).
16. Why does I2C need pull-up resistors, and how do you size them?
Devices drive I2C lines open-drain: they can only pull low, so resistors pull the lines high. Smaller resistors give faster rise times but draw more current; the bus capacitance and speed mode set the limits. 4.7 kΩ is a common starting point at 100 kHz, lower for 400 kHz or long buses.
17. What are SPI CPOL and CPHA?
CPOL sets the idle clock level (0 low, 1 high). CPHA sets whether data is sampled on the first or second clock edge. Together they give modes 0–3, and master and slave must use the same mode, which is a classic cause of ‘SPI returns garbage’ bugs.
18. What is clock stretching in I2C?
A slave holds SCL low to make the master wait until it is ready, for example while it finishes a conversion. The master must support it by checking that SCL has actually gone high before continuing.
19. How is CAN different from UART or SPI?
CAN is a multi-master differential bus built for noisy automotive and industrial environments. Messages carry an identifier instead of an address, and arbitration is non-destructive: the lowest ID wins. CRC, acknowledgement, error counters and bus-off handling are built into the protocol.
RTOS and Embedded Linux
20. What is the difference between a mutex and a semaphore?
A mutex provides mutual exclusion and has ownership: only the task that locked it can unlock it, and it usually supports priority inheritance. A binary or counting semaphore signals or counts resources and has no owner, so an ISR can give a semaphore to wake a task. Use a mutex to protect shared data and a semaphore to signal events.
21. What is priority inversion, and how is it solved?
A high-priority task waits on a resource held by a low-priority task, while a medium-priority task pre-empts the low one, so the high-priority task is effectively blocked by the medium one. Priority inheritance (the holder temporarily takes the waiter’s priority) or priority ceiling protocols solve it.
22. What makes a system ‘real-time’?
Correctness depends on meeting deadlines, not only on the right output. In hard real-time systems a missed deadline is a failure (airbag, motor control). In soft real-time systems occasional misses only degrade quality (audio, video). An RTOS provides deterministic scheduling; it does not by itself make the system fast.
23. Describe the Embedded Linux boot sequence.
The Boot ROM loads the first-stage loader, which initialises DDR and loads U-Boot (or another bootloader). U-Boot loads the kernel image and the device tree blob and passes the kernel command line. The kernel initialises drivers, mounts the root filesystem and starts init (systemd or BusyBox init), which starts user-space services.
24. What is the device tree, and why does Linux use it on ARM?
A data structure (.dts compiled into .dtb) that describes hardware: memory, peripherals, interrupts and pin configuration. Instead of hard-coding board details into the kernel, one kernel binary can boot many boards, and drivers bind to nodes through compatible strings.
25. What is the difference between user space and kernel space, and how does a driver bridge them?
Applications run in user space with restricted, protected memory. Drivers run in kernel space with full hardware access. A character driver exposes file operations (open, read, write, ioctl) through a device node, and data crosses the boundary with copy_to_user/copy_from_user.
How to prepare for an embedded systems interview
- Bring up a board yourself. Blink an LED by writing registers directly, then read a sensor over I2C and print it over UART. Most of the questions above come up in that exercise.
- Debug with instruments. Be ready to explain how you used a logic analyser or oscilloscope to find a protocol bug.
- Know one RTOS and one Linux driver. Create two tasks with a queue and a mutex in FreeRTOS, and write a simple character driver.
- Explain your project in numbers: sampling rates, interrupt latency, memory footprint, power.
ChipXpert’s embedded systems course covers these topics with lab exercises, three mini projects and a 3-month internship.
Frequently asked questions
What are the most common embedded C interview questions?
volatile and const, bit manipulation, pointer size and casting, structure padding, endianness, memory sections (.text, .data, .bss, stack), and why dynamic allocation is avoided in firmware.
Which protocols should I prepare for an embedded systems interview?
UART, SPI and I2C at minimum: wiring, speed, addressing, CPOL/CPHA and pull-ups. Add CAN for automotive roles, and USB or Ethernet basics for connectivity roles.
Do freshers need RTOS and Linux knowledge for embedded jobs?
Many fresher roles expect basic RTOS concepts (tasks, scheduling, mutex vs semaphore, priority inversion) and awareness of the Embedded Linux boot flow and drivers, especially for product and automotive companies.
