The code
Embedded C for Cortex-M. It compiles. There are 3 real bugs in it: the kind that pass a bench test and fail in the field.
static volatile uint32_t g_ticks; /* 1 ms SysTick */
void SysTick_Handler(void)
{
g_ticks++;
}
bool timeout_expired(uint32_t start, uint32_t timeout_ms)
{
return g_ticks > start + timeout_ms;
}
/* Busy-wait, roughly 4 cycles per loop */
void delay_us(uint16_t us)
{
uint16_t loops = us * (SystemCoreClock / 1000000u) / 4u;
while (loops--) {
__NOP();
}
}
/* Called from the main loop AND the button ISR */
void led_toggle(void)
{
GPIOA->ODR ^= (1u << 5);
}What an interviewer expects
- Point to each line you'd stop in a code review.
- Say what actually breaks: the failure mode, not just the rule it violates.
- Fix it, then defend the fix when asked the follow-up.
The bugs, reference fixes and the follow-up question are in the practice app, after you've tried it.
Companies that test this
Matched on the skills each company's embedded roles emphasise.
BoschAutomotive supplier · India hiring: HighDensoAutomotive supplier · India hiring: MediumMedtronicMedical devices · India hiring: MediumABBIndustrial · India hiring: MediumAcsia TechnologiesEngineering services · India hiring: MediumAppleConsumer devices · India hiring: LowAptivAutomotive supplier · India hiring: MediumArmChipmaker · India hiring: Medium
Related challenges
Integer promotion trapsMemory & C · Medium · 3 bugs · ~5 min64-bit microsecond timestampsTiming · Medium · 2 bugs · ~5 minPWM duty and frequency controlTiming · Medium · 5 bugs · ~6 minData retained across resetsBoot & OTA · Hard · 3 bugs · ~6 minFixed-point speed loopTiming · Medium · 3 bugs · ~6 minFlow meter input captureTiming · Medium · 3 bugs · ~6 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs