HireHireInterview Quizzes › Embedded / Firmware Engineer

Embedded / Firmware Engineer Interview Questions

Think you're ready? These are the questions that actually decide Embedded / Firmware Engineer interviews. Warm up on Easy — then face the Hard round, where 95% of candidates crumble. 80 questions across 3 levels, instant score, completely free.

80Questions
3Difficulty levels
95%Fail the hard round
FreeInstant score
Easy
Warm-up · 20 Qs
Medium
Practical · 30 Qs
Hard
Brutal · 30 Qs
⚡ Take the Embedded / Firmware Engineer quiz — get your score →

The Embedded / Firmware Engineer interview questions

Below are the real questions, grouped by difficulty. Expand any one to reveal the correct answer and why — or take the timed quiz for a score you can share. Can you clear the Hard round?

Easy round 20 questions

A global flag is set inside an ISR and polled by `while(flag);` in main. Without `volatile`, what can go wrong?
  • A. The compiler may cache flag in a register so the loop never sees the ISR's update ✓
  • B. The flag becomes automatically atomic
  • C. The ISR is prevented from modifying a global variable
  • D. The loop simply runs faster
Correct answer: A. Without volatile the optimizer can hoist the read out of the loop, so the ISR's change is never observed.
Which statement sets bit 3 of REG while leaving all other bits unchanged?
  • A. REG &= ~(1 << 3)
  • B. REG |= (1 << 3) ✓
  • C. REG ^= 0xFF
  • D. REG = (1 << 3)
Correct answer: B. ORing with a single set bit turns that bit on without disturbing the others.
Which statement clears bit 5 of REG without affecting other bits?
  • A. REG |= (1 << 5)
  • B. REG ^= (1 << 5)
  • C. REG &= ~(1 << 5) ✓
  • D. REG = 0
Correct answer: C. ANDing with the inverted mask forces bit 5 to 0 while preserving every other bit.
How do you test whether bit 2 of REG is currently set?
  • A. if (REG | (1 << 2))
  • B. if (REG & (1 << 2)) ✓
  • C. if (REG << 2)
  • D. if (!(REG & 2))
Correct answer: B. ANDing with the bit mask isolates bit 2; a non-zero result means it is set.
What is the minimum number of signal lines an I2C bus needs?
  • A. One line (data only)
  • B. Two lines (SDA and SCL) ✓
  • C. Three lines plus chip select
  • D. Four lines (MOSI, MISO, SCLK, CS)
Correct answer: B. I2C is a two-wire bus using a shared data line (SDA) and clock line (SCL).
Which serial interface is full-duplex, letting a device send and receive at the same time?
  • A. I2C
  • B. SPI ✓
  • C. Standard UART with one wire
  • D. 1-Wire
Correct answer: B. SPI has separate MOSI and MISO lines, so data flows both directions simultaneously.
A UART transmitter is set to 9600 baud but the receiver is configured for 19200. What is the result?
  • A. Data transfers correctly at the lower rate
  • B. The received bytes are garbled/corrupted ✓
  • C. The link automatically negotiates a common rate
  • D. Only the parity bit is affected
Correct answer: B. UART has no clock line, so a baud-rate mismatch samples bits at the wrong times and produces garbage.
A GPIO input has a pull-up resistor and an active-low button to ground. What does the pin read when the button is not pressed?
  • A. Logic low (0)
  • B. Logic high (1) ✓
  • C. It floats unpredictably
  • D. It draws maximum current
Correct answer: B. With the button open, the pull-up holds the pin high; pressing it pulls the pin low.
Which of these is bad practice to do inside an interrupt service routine?
  • A. Setting a volatile flag
  • B. Clearing the interrupt source
  • C. Calling a long blocking delay or printf ✓
  • D. Reading a hardware register
Correct answer: C. ISRs must return fast; long or blocking calls stall other interrupts and the main loop.
If firmware fails to periodically feed (kick) the watchdog timer, what happens?
  • A. The MCU resets ✓
  • B. The MCU enters low-power sleep
  • C. The interrupt priority is raised
  • D. Nothing until the next power cycle
Correct answer: A. An un-serviced watchdog assumes the firmware has hung and forces a system reset.
The 32-bit value 0x12345678 is stored little-endian. Which byte sits at the lowest memory address?
  • A. 0x12
  • B. 0x34
  • C. 0x56
  • D. 0x78 ✓
Correct answer: D. Little-endian stores the least-significant byte (0x78) at the lowest address.
In the declaration `const char *p`, what exactly is constant?
  • A. The pointer cannot be reassigned but the data can change
  • B. The data pointed to cannot be modified but the pointer can be reassigned ✓
  • C. Both the pointer and the data are constant
  • D. Neither is constant; const is ignored here
Correct answer: B. `const char *p` protects the pointed-to characters; the pointer itself may still point elsewhere.
In a resource-constrained firmware task, what most commonly causes a stack overflow?
  • A. Declaring a global array
  • B. A large local array or deep recursion exceeding the task's stack ✓
  • C. Using const variables
  • D. Enabling compiler optimization
Correct answer: B. Big automatic (local) buffers and unbounded recursion consume stack space that is very limited on MCUs.
A 10-bit ADC uses a 3.3 V reference. What is the approximate voltage per LSB (step)?
  • A. About 3.2 mV per step ✓
  • B. About 12.9 mV per step
  • C. About 3.3 mV is the full range
  • D. About 1.6 mV per step
Correct answer: A. 3.3 V divided by 1024 steps is roughly 3.2 mV per count.
An 8-bit ADC with a 3.3 V reference returns a reading of 128. What input voltage does that represent?
  • A. About 0.83 V
  • B. About 1.65 V ✓
  • C. About 2.48 V
  • D. About 3.30 V
Correct answer: B. 128/256 × 3.3 V is about 1.65 V, the mid-scale reading.
An LED is driven by PWM. Comparing a 25% duty cycle to 75%, what do you observe?
  • A. 25% duty makes the LED brighter than 75%
  • B. Duty cycle has no effect on brightness
  • C. 25% duty makes the LED dimmer than 75% ✓
  • D. Both give the same average brightness
Correct answer: C. Lower duty cycle means the LED is on for less of each period, so average current and brightness drop.
In an RTOS, what is a mutex primarily used for?
  • A. To count available instances of a resource
  • B. To provide ownership-based mutual exclusion for a shared resource ✓
  • C. To generate periodic interrupts
  • D. To increase clock speed
Correct answer: B. A mutex enforces that only its owning task holds a shared resource at a time, unlike a counting semaphore.
Two tasks each hold a resource and block waiting for the resource the other holds. What is this condition called?
  • A. Priority inversion
  • B. Deadlock ✓
  • C. Starvation
  • D. Context switch
Correct answer: B. Mutual, circular waiting on held resources is the definition of a deadlock.
A 32-bit variable is shared between an ISR and main on an 8-bit MCU without protection. What is the risk?
  • A. It is always safe because the CPU is single-core
  • B. A torn read/write (race) can occur; access must be made atomic ✓
  • C. The compiler serializes all access automatically
  • D. Only the ISR can ever read it
Correct answer: B. The 8-bit CPU accesses 32 bits in several steps, so an interrupt mid-access can corrupt the value unless made atomic.
Where should you store calibration constants so they survive a power cycle or reset?
  • A. In a RAM global variable
  • B. On the CPU stack
  • C. In non-volatile memory such as flash or EEPROM ✓
  • D. In a CPU register
Correct answer: C. Only non-volatile memory like flash or EEPROM retains data when power is removed; RAM, stack, and registers are lost.

Medium round 30 questions

You declare a global flag `int flag;` that is set inside an ISR and polled in your main `while` loop. On `-O2` the main loop never sees the update, though it works on `-O0`. What is the correct fix?
  • A. Declare the flag as `volatile int flag;` ✓
  • B. Declare the flag as `static int flag;`
  • C. Add a `__attribute__((packed))` to the flag
  • D. Move the flag into the ISR's local scope
Correct answer: A. `volatile` tells the compiler the variable can change outside normal program flow, preventing it from caching the value in a register across the loop.
A 16 MHz microcontroller drives a UART at 9600 baud 8N1. Roughly how long does it take to transmit a single byte (including start and stop bits)?
  • A. About 1.04 ms ✓
  • B. About 104 us
  • C. About 8.3 us
  • D. About 10.4 ms
Correct answer: A. One 8N1 frame is 10 bits, and at 9600 baud each bit is ~104 us, so 10 bits take about 1.04 ms.
You need to read a 16-bit ADC over I2C where the value is split across two 8-bit registers, high byte first. Which expression correctly reconstructs the value from `hi` and `lo` (both `uint8_t`)?
  • A. `((uint16_t)hi << 8) | lo` ✓
  • B. `hi | (lo << 8)`
  • C. `(hi << 8) + (lo << 8)`
  • D. `(uint16_t)(hi + lo)`
Correct answer: A. The high byte must be shifted left by 8 and OR-ed with the low byte, and casting `hi` to 16-bit prevents the shift from overflowing an 8-bit promotion edge case.
Your firmware uses a hardware watchdog timer with a 2-second timeout. What is the primary purpose of periodically 'kicking' (feeding) it in your main loop?
  • A. To automatically reset the MCU if the firmware hangs or stops executing normally ✓
  • B. To keep the CPU clock synchronized with the RTC
  • C. To reduce power consumption during idle periods
  • D. To flush the UART transmit buffer on a fixed interval
Correct answer: A. A watchdog resets the system if it isn't fed within its timeout, recovering from lockups or infinite loops.
You want a GPIO input pin connected to a mechanical push button (button pulls the line to GND when pressed) to read a stable HIGH when not pressed, without adding an external resistor. What should you configure?
  • A. Configure the pin as input with the internal pull-up enabled ✓
  • B. Configure the pin as input with the internal pull-down enabled
  • C. Configure the pin as open-drain output driven HIGH
  • D. Configure the pin as floating input and read it twice
Correct answer: A. An internal pull-up holds the line HIGH when the button is open and lets it go LOW when the button connects the pin to ground.
In an SPI transaction, what is the role of the chip-select (CS/SS) line when a master communicates with one of several slaves on a shared bus?
  • A. It selects which slave is active, and each slave ignores clock/data unless its CS is asserted ✓
  • B. It provides the clock signal that all slaves synchronize to
  • C. It carries the acknowledge bit back from the addressed slave
  • D. It sets the SPI mode (CPOL/CPHA) for the selected slave
Correct answer: A. SPI slaves only respond when their individual chip-select line is asserted (usually active-low), so CS chooses the target device.
A bare-metal button read shows multiple spurious presses for a single physical push. What is the standard firmware technique to fix this?
  • A. Debounce the input by requiring the level to remain stable for a few milliseconds before accepting it ✓
  • B. Increase the GPIO drive strength on the input pin
  • C. Enable an internal pull-down and read the pin faster
  • D. Route the button through the ADC instead of a digital GPIO
Correct answer: A. Mechanical contacts bounce for a few milliseconds, so debouncing (in software or hardware) filters out the transient transitions.
In a linker script / startup context, which memory segment holds initialized global variables whose values must be copied from flash to RAM at startup?
  • A. .data ✓
  • B. .bss
  • C. .text
  • D. .rodata
Correct answer: A. `.data` holds initialized globals; their initial values live in flash and startup code copies them to RAM, while `.bss` (zero-initialized) is just cleared.
You use a hardware timer to generate a periodic 1 kHz interrupt for a control loop. Inside the ISR you currently do a full sensor read, a floating-point PID calculation, and a UART debug print. What is the best practice fix?
  • A. Keep the ISR minimal (e.g. set a flag or timestamp) and do the heavy work in the main loop ✓
  • B. Raise the ISR priority to the highest level so it always finishes
  • C. Disable all other interrupts for the duration of the ISR
  • D. Move the UART print earlier so it runs before the PID math
Correct answer: A. ISRs should be short and deterministic; long work (especially blocking UART) belongs in the main context, triggered by a flag the ISR sets.
In an RTOS, a low-priority task holds a mutex that a high-priority task needs, and a medium-priority task keeps preempting the low-priority one, so the high-priority task is blocked indefinitely. What is this problem called, and what feature addresses it?
  • A. Priority inversion, addressed by priority inheritance on the mutex ✓
  • B. Deadlock, addressed by disabling preemption globally
  • C. Starvation, addressed by round-robin time slicing only
  • D. Race condition, addressed by making the variable volatile
Correct answer: A. This is classic priority inversion, and priority inheritance temporarily boosts the mutex holder's priority so it can release the lock quickly.
You share a multi-byte counter between an ISR and main loop on an 8-bit MCU and reads sometimes get a corrupted value. Correct fix?
  • A. Make the variable const
  • B. Disable interrupts (or use atomic access) while reading/writing the shared variable ✓
  • C. Increase the clock speed
  • D. Move the variable to flash
Correct answer: B. A multi-byte access is non-atomic on an 8-bit MCU, so an ISR firing mid-read tears the value; a critical section or atomic access prevents it.
Two devices on an I2C bus have the same 7-bit address. What is the consequence?
  • A. The bus runs at half speed
  • B. Address collision: the master cannot uniquely address them, causing bus conflicts ✓
  • C. Only the clock line is affected
  • D. Nothing, I2C auto-resolves it
Correct answer: B. I2C addresses must be unique per bus; duplicates cause both devices to respond, corrupting communication.
A UART link produces garbled characters and both ends use 8N1. What mismatch most commonly causes this?
  • A. Different cable colors
  • B. Mismatched baud rates ✓
  • C. Different PCB thickness
  • D. One uses SPI
Correct answer: B. UART is asynchronous; a baud-rate mismatch between transmitter and receiver garbles the sampled bits.
Declaring a hardware register pointer as 'volatile uint32_t *reg' achieves what that a plain pointer would not?
  • A. Faster access
  • B. Ensures every read/write actually accesses the hardware and isn't optimized away ✓
  • C. Allocates it in flash
  • D. Makes it thread-safe automatically
Correct answer: B. volatile forces actual memory accesses on each dereference, which is required for memory-mapped hardware registers.
You need to store calibration data that survives power cycles but changes occasionally at runtime, with no external storage. Which memory fits?
  • A. SRAM
  • B. CPU stack
  • C. EEPROM / emulated EEPROM in flash ✓
  • D. Program counter
Correct answer: C. EEPROM (or flash-emulated EEPROM) is non-volatile and rewritable, suited for occasionally-updated calibration data.
A low-priority task holds a mutex needed by a high-priority task while a medium-priority task keeps preempting the low one. What is this called?
  • A. Deadlock
  • B. Priority inversion ✓
  • C. Scheduler starvation
  • D. Race condition
Correct answer: B. This is priority inversion; the high-priority task is blocked indirectly by medium tasks running ahead of the low-priority mutex holder.
When sampling a mechanical push button, why is debouncing needed?
  • A. The button draws too much current
  • B. Mechanical contacts bounce, producing multiple rapid transitions per press ✓
  • C. The GPIO is too slow
  • D. The voltage is inverted
Correct answer: B. Mechanical contacts physically bounce for milliseconds, generating multiple edges that must be filtered in hardware or software.
You configure a timer with a 16 MHz clock and prescaler of 16. What auto-reload/compare value yields a 1 ms period?
  • A. 16
  • B. 160
  • C. 1000 ✓
  • D. 16000
Correct answer: C. 16 MHz / 16 = 1 MHz timer clock; 1 ms needs 1,000,000 * 0.001 = 1000 counts.
Which characteristic makes CAN bus well-suited for automotive networks?
  • A. Single-ended 3.3V signaling
  • B. Differential signaling with built-in arbitration and error detection ✓
  • C. It requires no termination
  • D. It is master-slave only
Correct answer: B. CAN uses differential pairs with non-destructive bitwise arbitration and robust error handling, ideal for noisy automotive environments.
In DMA-based peripheral transfers, what is the primary advantage over CPU-driven polling transfers?
  • A. Lower memory usage always
  • B. The CPU is freed to do other work while data moves in the background ✓
  • C. It eliminates the need for interrupts entirely
  • D. It increases the clock frequency
Correct answer: B. DMA moves data between peripheral and memory without CPU intervention, freeing the CPU for other tasks.
You need to share a flag between an ISR and main loop on an 8-bit MCU. Besides volatile, what must you consider for a multi-byte variable?
  • A. Nothing, volatile is sufficient
  • B. Atomic access, e.g., disabling interrupts during the read/write of the multi-byte value ✓
  • C. Storing it in flash
  • D. Using floating point
Correct answer: B. A multi-byte access can be interrupted mid-update, so atomicity (e.g., brief interrupt disable) is required.
In SPI, what is the role of the CPOL and CPHA settings?
  • A. They set the baud rate
  • B. They define clock polarity and phase (the SPI mode) that must match between master and slave ✓
  • C. They select the chip address
  • D. They enable parity checking
Correct answer: B. CPOL/CPHA define the SPI mode (clock idle level and sampling edge); master and slave must agree.
A debounce is needed for a mechanical push button. Which approach is most appropriate?
  • A. Increase the ADC resolution
  • B. Sample the pin and require a stable state over a short time window (e.g., 10-20 ms) ✓
  • C. Add a stronger pull-up only
  • D. Raise the CPU clock speed
Correct answer: B. Debouncing requires filtering transient bounces by confirming the input remains stable over a few milliseconds.
Why is dynamic memory allocation (malloc/free) often discouraged in embedded firmware?
  • A. It is not supported by any compiler
  • B. It can cause heap fragmentation and non-deterministic timing in constrained systems ✓
  • C. It always uses flash memory
  • D. It disables interrupts permanently
Correct answer: B. Repeated malloc/free can fragment a small heap and cause non-deterministic behavior, risky in constrained real-time systems.
In an RTOS, what problem does priority inheritance solve?
  • A. Stack overflow
  • B. Priority inversion, where a low-priority task holding a mutex blocks a high-priority task ✓
  • C. Deadlock detection
  • D. Clock drift
Correct answer: B. Priority inheritance temporarily raises the mutex holder's priority to prevent unbounded priority inversion.
When configuring a timer for a precise 1 kHz interrupt on a 16 MHz clock, what mainly determines the interrupt period?
  • A. The GPIO drive strength
  • B. The prescaler and the auto-reload/compare value ✓
  • C. The ADC reference voltage
  • D. The UART baud rate
Correct answer: B. The prescaler divides the clock and the reload/compare value sets the count, together defining the period.
You read a sensor over I2C and it occasionally returns 0xFF for all bytes. Which is a likely cause worth checking first?
  • A. The MCU is too fast
  • B. Missing or incorrect pull-up resistors on SDA/SCL, or wrong device address/NACK ✓
  • C. The flash is full
  • D. The stack is too large
Correct answer: B. I2C is open-drain and needs pull-ups; missing pull-ups or a wrong address/NACK commonly yields all-ones reads.
What is the main benefit of using DMA to transfer data from a peripheral to memory?
  • A. It increases the clock frequency
  • B. It offloads the CPU so transfers happen without per-byte CPU intervention ✓
  • C. It removes the need for a stack
  • D. It doubles the flash size
Correct answer: B. DMA moves data directly between peripheral and memory, freeing the CPU from handling each byte.
In a linker script, what does the .bss section typically contain?
  • A. Initialized global variables copied from flash
  • B. Zero-initialized (uninitialized) global/static variables ✓
  • C. Executable code
  • D. Constant strings
Correct answer: B. .bss holds zero-initialized static/global data; startup code clears it to zero, so it occupies no flash image space.
A firmware over-the-air (OTA) update should be safe against power loss mid-flash. Which design most directly enables this?
  • A. A single application image with no bootloader
  • B. A dual-bank/A-B scheme with a bootloader that only switches after verifying the new image ✓
  • C. Storing the image in RAM only
  • D. Disabling the watchdog during update
Correct answer: B. An A/B (dual-bank) layout keeps a known-good image and only boots the new one after verification, surviving interrupted flashing.

Hard round 30 questions

An ISR sets a shared 32-bit `volatile uint32_t event_flags` and the main loop does `if (event_flags & 0x2) { event_flags &= ~0x2; }`. On a Cortex-M4 the flag is occasionally lost even though the variable is `volatile`. What is the precise root cause?
  • A. `volatile` does not force the variable into a CPU register, so the compiler re-reads stale memory
  • B. The main loop's `event_flags &= ~0x2` is a non-atomic read-modify-write; an ISR firing between the load and store overwrites the ISR's newly-set bit ✓
  • C. Cortex-M4 lacks cache coherency, so the ISR write never reaches the main-loop's view of memory
  • D. `volatile` disables the write buffer, so the store is dropped under back-to-back interrupts
Correct answer: B. The `&=` compiles to load-modify-store; if the ISR runs between the load and the store, its bit set is clobbered when the stale-modified value is written back, which volatile cannot prevent.
A high-priority task H is blocked waiting on a mutex held by a low-priority task L, while a medium-priority task M (which never touches the mutex) is CPU-bound and keeps preempting L. H misses its deadline. Under a priority-inheritance mutex, what specifically happens to break this?
  • A. L's priority is temporarily raised to H's priority while it holds the mutex, so M can no longer preempt L, letting L finish and release quickly ✓
  • B. M is temporarily demoted below L until the mutex is released
  • C. H's priority is lowered to L's so all three tasks run round-robin
  • D. The scheduler boosts M to H's priority to flush it out of the critical section faster
Correct answer: A. Priority inheritance raises the mutex holder (L) to the priority of the highest waiter (H) for the duration it holds the lock, so intermediate task M can no longer preempt it and the unbounded inversion is bounded.
On a Cortex-M7 with D-cache enabled, the CPU fills a TX buffer in a cacheable region, then starts a memory-to-peripheral DMA from that buffer. The peripheral transmits stale bytes. Assuming write-back caching, what is the correct fix?
  • A. Invalidate the cache lines covering the buffer before starting the DMA
  • B. Clean (flush) the cache lines covering the buffer before starting the DMA, ensuring the buffer is cache-line aligned and padded ✓
  • C. Disable interrupts around the DMA start to prevent reordering
  • D. Insert a DSB barrier before the DMA start; the barrier flushes dirty lines
Correct answer: B. For CPU→peripheral transfers the dirty CPU-written data sits in cache, so you must clean/flush those lines to main memory before the DMA reads them; alignment/padding avoids corrupting adjacent data on partial lines.
After a crash with no debugger attached, you recover from RAM: LR (EXC_RETURN) = 0xFFFFFFFD, and the stacked frame shows PC pointing into a valid function but the fault was a precise BusFault. What does EXC_RETURN 0xFFFFFFFD tell you about where to read the stacked registers?
  • A. The exception used the FPU extended frame; read from MSP
  • B. Return to Thread mode using the Process Stack Pointer (PSP), so the stacked R0-R3, R12, LR, PC, xPSR are on the PSP ✓
  • C. Return to Handler mode using MSP; the frame is on the MSP
  • D. The value is invalid; EXC_RETURN must be 0xFFFFFFF9 for a valid frame
Correct answer: B. EXC_RETURN 0xFFFFFFFD means return to Thread mode with PSP and the basic (non-FP) frame, so the stacked exception context must be read from the PSP, not the MSP.
A single-producer/single-consumer lock-free ring buffer uses `head` (written by ISR producer) and `tail` (written by task consumer). On a weakly-ordered Cortex-A core, the consumer sometimes reads a slot before the producer's data write is visible. Where must a barrier go, and why?
  • A. The producer must write the data slot, then execute a write barrier (DMB), then publish the incremented `head`, so data is visible before the index that exposes it ✓
  • B. Only the consumer needs a barrier, after reading `head`
  • C. Barriers are unnecessary if `head` and `tail` are `volatile`
  • D. Wrap both index updates in a spinlock; barriers cannot help SPSC buffers
Correct answer: A. The producer must ensure the data store is globally visible before the head-index store that publishes it, which requires a write barrier between the payload write and the index update on a weakly-ordered core.
You must clear bit 3 of a peripheral control register that also has a write-1-to-clear (W1C) interrupt-status field in the same 32-bit word. Doing `REG |= (1<<3)` on the whole word is dangerous. Why?
  • A. `|=` is atomic so it is actually safe here
  • B. The read-modify-write reads the currently-set W1C status bits and writes them back as 1, inadvertently clearing pending interrupt flags ✓
  • C. Writing to a control register always triggers a bus fault on partial words
  • D. The compiler will optimize away the load since the register is not volatile
Correct answer: B. A read-modify-write reads any currently-asserted W1C status bits as 1 and writes them back, which acknowledges/clears those interrupts as an unintended side effect; such registers need field-isolated or byte-wise access per the datasheet.
A firmware image does OTA via A/B partitions. After flashing slot B and rebooting into it, the device must decide whether the update is good. Which mechanism gives atomic rollback if slot B boots but fails a health check?
  • A. Erase slot A immediately after flashing B so there is no ambiguity
  • B. Boot B with a one-shot 'trial' flag; B must actively confirm (set 'confirmed') within a health window, else the bootloader reverts to A on the next reset ✓
  • C. Compute a CRC of B before boot; if it matches, mark B permanent
  • D. Copy B over A during boot so both slots are identical
Correct answer: B. A trial/pending flag that the new image must explicitly confirm after passing health checks lets the bootloader automatically fall back to the known-good slot if the confirmation never arrives, giving atomic rollback.
A battery sensor node wakes every second to sample and drains far faster than budgeted. Measured current in 'sleep' is ~1.2 mA instead of the expected few µA. Which cause is most consistent with this symptom?
  • A. The core enters WFI but a peripheral clock (e.g., a running timer or unstopped ADC/UART) and its clock domain were left ungated, keeping a high-power domain active ✓
  • B. WFI is the wrong instruction; WFE would reach a deeper mode
  • C. The MCU cannot reach stop mode because interrupts are globally disabled
  • D. Flash wait states are too high, increasing active current
Correct answer: A. A residual ~1 mA floor during 'sleep' typically means a peripheral/clock domain (timer, ADC, UART, or an unstopped oscillator) was not gated, so the part never truly entered the low-power state despite executing WFI.
Two tasks each need mutex A and mutex B. Task1 locks A then B; Task2 locks B then A. Occasionally the system hangs with both blocked. Besides using timeouts, what is the canonical structural fix?
  • A. Convert both mutexes to counting semaphores with count 2
  • B. Enforce a global lock-ordering discipline so every task always acquires A before B ✓
  • C. Raise Task1's priority above Task2 so it always wins
  • D. Disable preemption while any mutex is held
Correct answer: B. A circular wait requires two tasks to acquire the same locks in opposite orders; imposing a single consistent global acquisition order eliminates the cycle and thus the deadlock by construction.
A task set on a single core has periods/WCETs: T1(P=10,C=3), T2(P=15,C=4), T3(P=30,C=8), scheduled rate-monotonic (shorter period = higher priority). Total utilization U = 0.3+0.267+0.267 = 0.834. What can you conclude about schedulability?
  • A. U < 1 so it is definitely schedulable under RMS
  • B. U = 0.834 exceeds the n=3 Liu-Layland bound (~0.780), so the sufficient test fails; schedulability is inconclusive and needs an exact response-time analysis ✓
  • C. U > 0.780 so it is definitely NOT schedulable
  • D. RMS cannot schedule three tasks; use EDF
Correct answer: B. The Liu-Layland utilization bound is only sufficient, not necessary; since U exceeds the ~0.78 bound for 3 tasks you cannot conclude either way and must run an exact response-time (worst-case) analysis.
An ARM Cortex-M firmware hard-faults intermittently only with optimization enabled, near a struct accessed via a cast pointer. Most likely cause?
  • A. Stack overflow only at -O0
  • B. Unaligned memory access to a 32-bit value the compiler assumed aligned ✓
  • C. Flash wear-out
  • D. Interrupt vector table missing
Correct answer: B. Optimized code may emit word accesses assuming alignment; a misaligned pointer cast then triggers an alignment/usage fault on Cortex-M.
An ISR sets a global int flag that main polls, but with -O2 main never sees the update even though the ISR runs. Fix?
  • A. Declare the flag static
  • B. Declare the flag volatile so the compiler re-reads it from memory ✓
  • C. Increase the optimization level
  • D. Move main() logic into the ISR
Correct answer: B. Without volatile the compiler may cache the flag in a register in the polling loop; volatile forces a memory re-read each iteration.
You must guarantee a write to one peripheral register completes before reading another on Cortex-M. Which barrier is appropriate?
  • A. NOP
  • B. DMB/DSB (data memory/synchronization barrier) ✓
  • C. WFI
  • D. SVC
Correct answer: B. A DMB or DSB memory barrier enforces ordering/completion of memory accesses when required for peripheral sequencing.
Firmware using flash-emulated EEPROM starts corrupting data after months in the field. Most likely root cause?
  • A. Baud rate drift
  • B. Flash endurance/wear exhaustion from too many erase cycles on one sector ✓
  • C. Watchdog too long
  • D. I2C address conflict
Correct answer: B. Flash cells have limited erase/write endurance; without wear leveling, frequent writes to one sector exhaust it and cause corruption.
An interrupt-driven ring buffer (ISR increments head, main increments tail) occasionally loses bytes at high data rates. Most likely subtle bug?
  • A. Tail is signed
  • B. The full/empty check races because index updates or wrap aren't handled atomically/correctly ✓
  • C. The buffer is in flash
  • D. The UART is 8N2
Correct answer: B. Lock-free single-producer/consumer ring buffers require careful atomic index ordering; incorrect full/empty checks or non-atomic updates drop or overwrite data.
An RTOS task occasionally misses its deadline under load, and adding a lower-priority task made it worse. Best mitigation for the underlying priority inversion?
  • A. Round-robin time slicing
  • B. Priority inheritance on the shared mutex ✓
  • C. Disabling the scheduler
  • D. Increasing tick frequency only
Correct answer: B. Priority inheritance temporarily raises the mutex holder's priority to that of the highest waiter, bounding the inversion.
A sensor read over SPI works at 1 MHz but returns garbage at 8 MHz, with degraded signals on a scope. Most likely cause?
  • A. Wrong I2C address
  • B. Signal integrity issues (trace length, capacitance, missing termination) exceeding slave timing at higher clock ✓
  • C. The MCU ran out of RAM
  • D. The compiler optimized the read
Correct answer: B. At higher SPI clocks, PCB parasitics and inadequate termination degrade edges beyond the slave's setup/hold timing, corrupting data.
During a firmware over-the-air update, power loss mid-write can brick the device. Which design prevents this?
  • A. Single-bank flash overwrite in place
  • B. Dual-bank (A/B) flash with a bootloader that switches only after full verification ✓
  • C. Writing directly over the running image
  • D. Disabling the watchdog during update
Correct answer: B. Dual-bank A/B updates keep a valid image intact and switch only after the new image is fully written and verified, making updates power-fail safe.
A Cortex-M enters a fault only sometimes when a specific FreeRTOS task runs, and configASSERT points to stack. Most probable cause?
  • A. Task stack overflow corrupting adjacent memory or the TCB ✓
  • B. Flash too small
  • C. Wrong endianness
  • D. UART parity error
Correct answer: A. An undersized task stack overflows into neighboring memory depending on call depth and ISR nesting, causing sporadic faults.
You need microsecond-accurate, jitter-free periodic pulses on a pin while the CPU handles other work. Best approach?
  • A. A software delay loop in main
  • B. A hardware timer in output-compare/PWM mode driving the pin directly ✓
  • C. Bit-banging inside a low-priority RTOS task
  • D. Polling a GPIO in a tight loop
Correct answer: B. A hardware timer in output-compare/PWM mode toggles the pin in hardware with deterministic timing, immune to CPU load and interrupt jitter.
On a Cortex-M, an ISR writes to a peripheral register then the main code disables the peripheral immediately after, but the write seems lost. What mechanism most likely explains this?
  • A. Cache coherency on the MCU core
  • B. Write buffering/store ordering; a DSB/memory barrier or read-back is needed to ensure the write completed ✓
  • C. Stack corruption
  • D. Incorrect endianness
Correct answer: B. The write buffer may not have drained; a memory barrier (DSB) or register read-back ensures the peripheral write completes before subsequent actions.
You measure that an interrupt occasionally has ~50 microseconds of extra latency on a Cortex-M. Which is the most likely firmware cause?
  • A. Flash is nearly full
  • B. Long critical sections that disable interrupts, or a higher/equal priority ISR running ✓
  • C. Using volatile variables
  • D. The linker placed code in RAM
Correct answer: B. Interrupt latency jitter typically comes from interrupts being disabled in critical sections or another same/higher-priority handler running.
A struct mapped over a memory-mapped peripheral works with -O0 but breaks at -O2. What is the most likely root cause?
  • A. The optimizer inlined main()
  • B. Register fields not declared volatile, so the compiler reorders or eliminates accesses ✓
  • C. The heap is too small
  • D. printf is not reentrant
Correct answer: B. Peripheral registers must be volatile; without it, aggressive optimization reorders/coalesces or removes the required hardware accesses.
Two tasks in an RTOS occasionally deadlock. Task A locks mutex X then Y; Task B locks Y then X. What is the standard prevention technique?
  • A. Increase both task priorities equally
  • B. Enforce a global lock ordering so all tasks acquire mutexes in the same order ✓
  • C. Use larger stacks
  • D. Disable the scheduler tick
Correct answer: B. Consistent global lock ordering prevents the circular-wait condition required for deadlock.
A battery device draws far more sleep current than expected. After entering STOP mode, which oversight most commonly causes this?
  • A. The watchdog is enabled
  • B. Floating GPIO inputs or peripherals/clocks left enabled sinking current ✓
  • C. Using an RTOS
  • D. The flash wait states are too high
Correct answer: B. Floating inputs can oscillate and draw current, and leaving peripherals/clocks on defeats low-power modes, raising sleep current.
You need to guarantee a hard real-time deadline of 100 microseconds for a control loop. Which implementation choice is most robust?
  • A. A high-priority preemptive interrupt/timer-driven handler with bounded execution time ✓
  • B. Polling inside a low-priority background task
  • C. A delay loop calibrated at boot
  • D. Handling it in the RTOS idle hook
Correct answer: A. A high-priority timer interrupt with bounded, deterministic execution reliably meets a tight hard-real-time deadline.
In a CAN bus network, a node's transmitted dominant bit is overwritten during arbitration. What does the CAN protocol do?
  • A. It raises a bus-off error immediately
  • B. The node loses arbitration and switches to receive, retrying later without corrupting the winning frame ✓
  • C. Both frames are discarded
  • D. The bus resets
Correct answer: B. CAN's non-destructive bitwise arbitration lets the lower-priority node back off and retransmit while the higher-priority frame proceeds intact.
A firmware image runs correctly from the debugger but fails on cold boot from flash. Which startup issue is the most likely culprit?
  • A. Missing or incorrect data (.data) copy and .bss zeroing in the reset handler / startup code ✓
  • B. Too many volatile variables
  • C. Incorrect UART baud rate
  • D. The optimizer level is too low
Correct answer: A. The debugger may pre-initialize RAM, masking a startup that fails to copy .data from flash or zero .bss on a real cold boot.
You need to detect single-bit corruption in a critical config block stored in EEPROM. Which is the most appropriate lightweight integrity mechanism?
  • A. Store the data twice with no check
  • B. Append a CRC (e.g., CRC-16/CRC-32) and verify it on read ✓
  • C. Encrypt with AES only
  • D. Use a longer variable name
Correct answer: B. A CRC reliably detects bit errors in stored data at low computational cost, unlike encryption which provides confidentiality, not integrity checking.
An ADC reading is noisy at exactly the PWM frequency driving a nearby motor. Beyond software filtering, which hardware-aware fix best addresses the root cause?
  • A. Increase the MCU clock
  • B. Improve PCB layout/grounding and synchronize ADC sampling away from PWM switching edges ✓
  • C. Use a larger stack
  • D. Switch from C to assembly
Correct answer: B. The noise is switching-induced coupling; better grounding/layout and sampling away from PWM edges attacks the source rather than masking it.

Prep for another role

Questions are original, written and independently verified for HireHire's role interview quizzes. They reflect the kind of knowledge Embedded / Firmware Engineer interviews test, not any specific company's questions. HireHire maps live tech & IT jobs across India, updated regularly. Last updated: August 2026.