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.
#define KP_Q16 ((int32_t)(4.5 * 65536))
#define KI_Q16 ((int32_t)(0.8 * 65536))
static int32_t integ;
int16_t pi_step(int16_t target_rpm, int16_t rpm)
{
int32_t err = target_rpm - rpm;
integ += err;
int32_t out = (KP_Q16 * err + KI_Q16 * integ) >> 16;
return (int16_t)out;
}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
Tick timeouts and delaysTiming · Warm-up · 3 bugs · ~4 minInteger 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 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