The code
Embedded C for Cortex-M. It compiles. There are 4 real bugs in it: the kind that pass a bench test and fail in the field.
static volatile int16_t touch_x, touch_y;
void EXTI9_5_IRQHandler(void)
{
EXTI->PR1 = EXTI_PR1_PIF7;
uint8_t buf[4];
HAL_I2C_Mem_Read(&hi2c1, TP_ADDR << 1, TP_REG_XY,
I2C_MEMADD_SIZE_8BIT, buf, 4, 100);
uint16_t rx = (uint16_t)((buf[0] << 8) | buf[1]);
uint16_t ry = (uint16_t)((buf[2] << 8) | buf[3]);
touch_x = (int16_t)(rx * 480 / 4096);
touch_y = (int16_t)(ry * 272 / 4096);
}
bool touch_get(int16_t *x, int16_t *y)
{
*x = touch_x;
*y = touch_y;
return true;
}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.
ABBIndustrial · India hiring: MediumAcsia TechnologiesEngineering services · India hiring: MediumAMD IndiaChipmaker · India hiring: MediumAnalog DevicesChipmaker · India hiring: MediumAther EnergyEV OEM · India hiring: MediumDysonConsumer devices · India hiring: LowEatonIndustrial · India hiring: HighHarmanAutomotive supplier · India hiring: High
Related challenges
ADC with circular DMADMA & graphics · Hard · 3 bugs · ~7 minLogging over UART with DMADMA & graphics · Medium · 3 bugs · ~5 minLTDC double bufferingDMA & graphics · Hard · 3 bugs · ~7 minLVGL flush callback with DMA2DDMA & graphics · Medium · 3 bugs · ~5 minSPI DMA on a cached coreDMA & graphics · Hard · 3 bugs · ~7 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs