Flash memory is slower than a fast CPU core. At low clock speeds the core can fetch an instruction from flash in a single cycle, but as you raise the clock, the flash access time eventually exceeds one core cycle, so the core must insert wait states, extra cycles where it pauses for the flash to deliver valid data. The wait-state count is a configurable setting that must match the core frequency per the datasheet's frequency-vs-latency table. The ordering is critical: if you raise the core clock before increasing the flash wait states, the core starts fetching instructions faster than the flash can supply them, reads invalid/partial data, and almost always HardFaults or hangs immediately, a bricked-looking chip. So the sequence is: increase flash latency first, then switch to the higher clock. When lowering the clock you do the reverse, drop the clock first, then reduce wait states. This is one of the most common bugs in hand-written clock-init code.
Embedded Systems Fundamentals · Interview question
Why must you set flash wait states before increasing the core clock?
A strong answer
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
Clocks & the Clock Tree
The MCU's heartbeat: internal RC vs external crystal vs PLL, and the clock tree that feeds the core and every peripheral, plus the flash-wait-state trap that hangs chips.
More Clocks & the Clock Tree questions
What's the difference between an internal RC oscillator and an external crystal, and when do you use each?What does the PLL do in the clock tree?A peripheral's timing (UART baud, timer period) is wrong. How does the clock tree factor in?What's the correct sequence to switch the system clock to a PLL running off an external crystal?
Browse all 472 interview questions