Home / Learn Embedded C / Interview Questions

Interview Questions

Beginner, intermediate and advanced embedded C interview questions with model answers.

The gistBeginner, intermediate and advanced embedded C interview questions with model answers.

The idea, explained simply

In plain terms

This page collects the kind of embedded C interview questions covered implicitly throughout this course, organized by difficulty, each with a model answer you can compare your own against.

Why we use it

Practicing answering these questions aloud, in your own words, before checking the model answer is far more effective interview preparation than simply reading the answers passively.

Under the hood

Each answer is deliberately concise, in the style suited to a spoken interview response, matching the "explaining X in an interview" lessons from the Interview Preparation group.

Real-world use

  • Interview preparation
  • Self-testing
  • Concept review

Short answers you can say in an interview. Click a question to open the answer. Say each answer aloud in your own words.

Beginner questions

What is the difference between a microcontroller and a microprocessor?

A microcontroller integrates a CPU, RAM, flash and peripherals (GPIO, timers, UART) on one chip; a microprocessor is just the CPU and needs separate chips for memory and I/O.

What does the volatile keyword do, and when do you need it?

It tells the compiler a variable can change outside its visible control flow (an ISR, a hardware register), so it must always be re-read from memory, never cached. Needed for ISR-shared variables and memory-mapped registers.

What is the difference between static at file scope and static inside a function?

At file scope, static limits a global's visibility to that one source file. Inside a function, static makes a local variable keep its value between calls instead of being reinitialized each time.

Why do embedded projects generally avoid using malloc?

Dynamic allocation on a long-running embedded system can fragment the small heap over time, and a failed allocation at an unpredictable moment is hard to handle safely — most embedded code prefers static or stack allocation instead.

What is the difference between #define and const?

#define is a preprocessor text substitution with no type information, applied before compilation; const creates a real, typed variable the compiler type-checks and that has an address, which is usually the safer, more debuggable choice.

What is a pull-up resistor and why would you use one?

A pull-up resistor weakly holds an input pin at a known HIGH level when nothing else is actively driving it, so a floating input (like an unpressed button) reads a defined, predictable value instead of noise.

What is the difference between push-pull and open-drain outputs?

Push-pull actively drives both HIGH and LOW; open-drain can only actively pull LOW and relies on a pull-up for HIGH — used on shared buses like I2C where multiple devices must not fight each other.

What does PWM stand for, and what is "duty cycle"?

Pulse Width Modulation: a fast digital on/off signal whose "duty cycle" (percentage of time spent HIGH) simulates an analog-like average level, used for LED dimming, motor speed and similar effects.

Intermediate questions

Explain what happens, step by step, when an interrupt fires.

The CPU finishes its current instruction, saves its state (registers, return address), looks up the matching handler address in the vector table, runs the ISR, then restores the saved state and resumes exactly where it left off.

Why should an ISR be kept as short as possible?

A long ISR blocks other (same or lower priority) interrupts from being serviced for its entire duration, which can cause missed events like dropped UART bytes — the standard pattern is to do minimal work in the ISR and defer the rest to the main loop.

What is a race condition in the context of an ISR and main-loop code?

It occurs when an ISR changes shared data in the middle of the main loop's own read-modify-write sequence on that same data, causing the main loop's write to silently overwrite or ignore the ISR's change.

What is the read-modify-write pattern, and why does it matter for registers?

Read the register's current value, modify only the bits you care about in a local copy, then write the whole value back in one write — this lets you change part of a multi-purpose register without disturbing unrelated bits.

What is a circular (ring) buffer, and where is it commonly used?

A fixed-size buffer with wrap-around read/write indices, commonly used to buffer bytes between a UART receive interrupt and the main loop, since it needs no dynamic allocation and naturally handles continuous data.

What is the difference between a mutex and a semaphore in an RTOS?

A mutex enforces strict single ownership of one resource at a time; a semaphore is a more general counting signal, often used for ISR-to-task signaling or limiting access to a pool of N resources.

What is priority inversion, and how is it typically prevented?

A high-priority task is indirectly delayed by a medium-priority task repeatedly preempting a low-priority task that holds a mutex the high-priority task needs. Priority inheritance (temporarily boosting the low-priority task) is the standard fix.

What does a watchdog timer do, and what is a common mistake when using one?

It resets the chip if not periodically "petted" by software, catching a hang. A common mistake is petting it from a location (like a free-running timer ISR) that does not actually prove the whole system is healthy.

Advanced questions

What is memory-mapped I/O, and why does it let ordinary C variable syntax touch hardware?

Peripheral registers are assigned regular memory addresses, so the same load/store instructions used for RAM also read/write hardware state — this is exactly what makes "GPIOA->ODR |= mask;"-style code work at all.

Why can struct member access to a register (like GPIOA->MODER) still have a read-modify-write race condition?

The friendly struct syntax still compiles down to a separate read, modify and write at the machine level — the readability improvement does not change the underlying hardware race risk if an ISR can interrupt it.

What is secure boot, and how does it differ from a simple CRC check on a firmware image?

A CRC only catches accidental corruption; secure boot cryptographically verifies the firmware's authenticity using a digital signature, which also stops a deliberately malicious image that happens to have a perfectly valid CRC.

Explain the bootloader-to-application handoff, including a common bug.

The bootloader validates the application image, relocates the vector table pointer to the application's own vector table, sets the stack pointer, then jumps to the application's reset handler. Forgetting the vector-table relocation is a classic bug: interrupts after the jump wrongly use the bootloader's own handlers.

Why is fixed-point math often used instead of floating-point on simple microcontrollers?

Chips without a hardware FPU emulate floating-point in slow software; fixed-point represents fractional values as scaled integers, giving fractional-value behavior using only fast, native integer arithmetic.

What is priority inversion's connection to a famous real-world embedded bug?

It was a documented real issue in the Mars Pathfinder mission, where a low-priority task holding a mutex was repeatedly preempted by a medium-priority task, indirectly delaying a high-priority task and triggering watchdog resets.

What does it mean for a build to be "reproducible", and why can an embedded team care about it?

Building the exact same source with the same toolchain always produces a bit-for-bit identical binary — useful for security audits and confirming a deployed binary really corresponds to a specific, auditable source commit.

How would you design error handling in C, given that C has no exceptions?

Typically through consistent function return codes (often an error-code enum) with the real result passed back via an output parameter, so callers can check for failure before trusting the result — applied consistently across the whole codebase.