Embedded Systems Fundamentals · Interview question

What's the difference between flash and SRAM on an MCU?

A strong answer

Flash is non-volatile memory that retains its contents without power; it holds the program code and read-only/const data, and the CPU typically executes directly from it. It's larger but slower (often needing wait-states at high clock speeds), and writing to it is slow, requires erase-before-write, and wears out after a limited number of cycles. SRAM is volatile, it loses its contents at power-off, and holds your runtime data: variables, the stack, and the heap. It's fast (often single-cycle access) and freely writable, but smaller and consumes standby power to retain data. So at runtime your code runs from flash while your mutable data lives in SRAM, and at boot the startup code copies initialized variables from flash into SRAM and zeroes the rest (the .data/.bss init, covered in the boot lesson). Knowing the split explains why globals persist, why string literals are read-only, and why you can't just "write a variable to flash" casually.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

Inside an MCU

The block diagram demystified: a CPU core, flash and SRAM, and peripherals wired together by internal buses, and why peripherals working in parallel with the CPU is the whole point.

More Inside an MCU questions

Browse all 472 interview questions
What's the difference between flash and SRAM on an MCU? | EmbeddedPrep.io