Skip to content
Tech Interview Prep
Technical interview guide

Communication Protocols: SPI, I2C, UART

The three workhorse serial buses for talking to peripherals and other boards: how each is wired and clocked, and when to reach for which.

Read
60 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: NXP UM10204 revision 7; CMSIS-Driver 6 SPI/I2C/USART interfaces; current Zephyr peripheral APIs reviewed 2026-09-04.

Curated: · Written: · Reviewed:

25 questions

MCQ-2An embedded design connects an MCU to an external high-speed flash, several low-speed environmental sensors, and a debug logging console. How do SPI, I2C, and UART compare across topology, physical signal count, and clock synchronicity when selecting interfaces for these peripherals?
MCQ-3A logic analyzer capture of an SPI link to a sensor shows the clock idling low, and the slave sampling MOSI on the clock's rising edge. The firmware driver was written assuming mode 0. The first byte read back is 0xFF instead of the expected 0x3A, and the sensor's data sheet specifies that it samples on the falling edge with the clock idling low. Which change to the driver's SPI configuration will make the read return the correct value?
MCQ-4An SPI sensor shifts MISO out MSB-first, one bit per clock, and reloads its output shift register from the addressed register on the last falling edge of the command byte. Until that load, the shift register keeps the byte the previous transaction put there. The last transaction read register 0x05, which held 0xA3. The driver now asserts CS, transfers 0x86 (read register 0x06, which holds 0x5C), then transfers 0x00 as a dummy byte, then deasserts CS. What do the two transfers return on MISO?
MCQ-5A driver talks to an SPI ADC at 8 MHz. The datasheet says the command byte is latched on the falling edge of CS, and CS must stay high for at least 50 ns between transactions. A logic-analyzer capture shows: CS falls, 16 SCLK cycles shift in a command for channel 3; CS stays low; 16 more SCLK cycles shift in a command for channel 7, which the analyzer confirms is correct on MOSI. Both reads return the channel-3 result. What is the cause?
MCQ-6A sensor node and its host MCU both run SPI mode 0 at 8 MHz with MSB-first shifting. The sensor's datasheet defines its 16-bit sample register as two bytes, high byte first, and the driver reads it as a single 16-bit word. On the bench the host decodes every sample as exactly 256 times the value the sensor's own evaluation GUI reports. The wiring, clock rate and mode are all confirmed correct on a scope. What is the most likely cause?
MCQ-1A team wires a 3.3 V SPI sensor to a 5 V MCU. Both datasheets list SPI mode 0, MSB-first, and the same clock rate, so the firmware engineer connects MOSI, MISO, SCLK and CS directly and powers the sensor from the 5 V rail. On the bench the sensor returns correct readings for a few minutes, then MISO goes low permanently and the sensor draws 40 mA at idle. What is the most likely cause?
MCQ-7A single SPI controller on an STM32F4 drives two devices: a flash chip strapped for mode 0 (CPOL=0, CPHA=0) at 21 MHz, and an accelerometer that only supports mode 3 (CPOL=1, CPHA=1) at 5 MHz. Both are wired to the same SCK/MOSI/MISO with separate chip selects. During a 4 KB flash read the driver is preempted by an interrupt handler that reads one accelerometer register, then returns. The flash read comes back with shifted, wrong bytes. What is the cause?
MCQ-11A temperature sensor's datasheet lists its 7-bit I2C address as 0x21. A logic-analyzer capture of a known-good board shows the byte 0x42 on the wire for a write to that sensor. An engineer writes a new driver and passes 0x42 to the HAL function i2c_write(uint8_t addr7, ...), which sends (addr7 << 1) | 0 as the address byte. What appears on the wire, and what does the sensor do?
MCQ-10A firmware engineer brings up a new board with a single I2C temperature sensor at address 0x48 on a 3.3 V bus with 4.7 kΩ pull-ups. A logic analyzer shows the master sending the address byte 0x90 (7-bit 0x48 plus the write bit), and the sensor pulling SDA low for the ninth clock. The master then writes the pointer register 0x00, sees SDA released high on the ninth clock, and stops. The engineer logs "sensor ACKed, reading is valid" and ships the driver. What does the analyzer trace actually establish?
MCQ-9An I2C sensor at 7-bit address 0x48 resets its register pointer to 0x00 on every STOP. Register 0x02 holds 0x1A. A driver writes 0x02, issues a repeated START, then sends the read address and clocks out one byte. What byte does the driver receive?
MCQ-13Two masters share a 100 kHz I2C bus. Both see the bus idle and begin transmitting in the same clock cycle. Master A sends the 7-bit address 0x50 with R/W = 0, then data byte 0xF0. Master B sends the same address 0x50 with R/W = 0, then data byte 0x0F. Both transmit MSB first. What data byte does the slave at 0x50 receive?
MCQ-24A firmware team ports an I2C temperature sensor driver to a new board. The sensor is at 0x48 on a 400 kHz bus, the datasheet maximum; its temperature register is 0x00, and writing the pointer starts a conversion. On the new board every read returns the previous conversion result: the reported temperature only changes on every second read. The driver log records each transfer as 'OK, ACK received', with timestamps taken in the ISR after the STOP condition. A logic analyzer capture shows: START, 0x48+W, ACK, pointer 0x00, ACK, repeated START, 0x48+R, ACK, two data bytes, NACK, STOP. With the repeated START 180 µs after the pointer byte's ACK. The datasheet specifies 1.1 ms for a 12-bit conversion and notes that the output register updates only when a conversion completes. What does the logic analyzer capture establish that the driver log cannot?
MCQ-8A 3.3 V I2C bus runs at 400 kHz with 10 kΩ pull-ups and a total bus capacitance of 200 pF. On the scope, SDA's 0.3–0.7 Vdd edge takes about 1.7 µs, and transactions NACK once the cable is long. What should the team do?
MCQ-25A 3.3 V I2C bus runs at 400 kHz with 4.7 kΩ pull-ups and about 200 pF of total capacitance from traces, connectors, and device pins. On the scope the edges are visibly exponential and the bus never settles at 3.3 V before the next clock edge, and the master intermittently sees NACKs. Which statement explains the trace and the change that fixes it?
MCQ-14A 3.3 V I2C bus runs at 100 kHz with 4.7 kΩ pull-ups. A master MCU, a fuel gauge, and an EEPROM share it. After a brownout the MCU resets mid-read of the gauge. On reboot the bus scan finds SDA held low with SCL high. The recovery routine releases both GPIOs and toggles SCL nine times at 100 kHz; SDA is still low after the ninth pulse. The gauge and the EEPROM each sit on a load switch the MCU controls, and the gauge has no SMBus timeout. What should the routine do next?
MCQ-12A 400 kHz hardware I2C controller reads a sensor every 100 ms. About one read in three aborts with a bus-timeout flag. A logic analyzer shows: START, address 0x76 with ACK, then after the 9th clock the controller releases SCL but SCL stays low for 1.2 ms while SDA remains high, after which the transfer completes normally. The controller's SCL-low timeout is 500 µs. What is the correct diagnosis and fix?
MCQ-15A sensor board and a host MCU are wired TX→RX, RX→TX with a common ground. Both UARTs are configured 115200 baud, 8 data bits, no parity, 1 stop bit. The host's UART is clocked from a 16 MHz crystal (±30 ppm). The sensor's UART is clocked from its internal RC oscillator, specified ±8% over temperature and measuring +7% at the cold end of the range. On the bench at 25 °C the link runs for hours with no errors. In the cold chamber the host logs a framing error on nearly every frame, and a logic analyzer shows the first six data bits decoding correctly while the last two data bits and the stop bit are wrong. What explains the cold-chamber failures?
MCQ-16A sensor streams 16-bit big-endian samples back-to-back over UART at 115200 8N1 with no header, delimiter, length or checksum; the host simply reads the stream in two-byte pairs. Fed the test pattern 0x0102, 0x0304, 0x0506, 0x0708, the host printed those values correctly until it was reset during a firmware update while the sender kept transmitting. Since then it prints 0x0203, 0x0405, 0x0607 and stays exactly that far out for hours, with no other change on the link. What explains the values it prints now?
MCQ-17A 115200-baud 8N1 telemetry link has a one-byte receive register and no DMA. A frame is 64 bytes: 62 raw payload bytes, which may take any value, plus a 2-byte CRC; there is no start delimiter, and the sender transmits one frame every 50 ms with the line idle in between. One byte time at 115200 8N1 is 86.8 microseconds. Once a second, a flash erase masks the UART receive interrupt for 1.1 ms. The interrupt returns mid-frame with the overrun flag set. What must the receive driver do?
MCQ-18A UART driver sends a 64-byte frame at 115200 baud, 8N1, using DMA and a completion interrupt. The peripheral can take up to 3 ms after the last byte before it asserts completion. A shared power-management ISR can gate the UART clock for up to 2 ms during the transfer. The driver sets a 6 ms transaction deadline. During stress testing, transactions occasionally time out. What is the correct diagnosis?
MCQ-19A Cortex-M board receives 256-byte blocks from an FPGA over UART at 921600 baud, 8N1 (10 bits per byte, so 10.85 us per byte) through a 16-byte RX FIFO that raises its interrupt at the half-full mark. The handler copies each byte into the frame buffer in 2 us and, when byte 256 lands, does 340 us of frame-end work in place: CRC32 over the buffer 300 us, copy into a queue slot 30 us, queue post 10 us. Vector-to-first-instruction latency is 3 us and no other handler runs longer than 12 us. The FPGA sends its blocks back to back from a clock that cannot be changed on this board. Under that load every block sets the overrun flag and loses bytes. Which single change keeps a block intact?
MCQ-20A firmware team streams 64-byte frames over a UART at 115200 baud, 8N1, using DMA. The DMA transfer-complete interrupt fires when the last byte has been written into the UART's transmit data register; at that instant the one-byte transmit FIFO and the shift register still hold data. The transmit buffer is a single static 64-byte array, reused as soon as the transfer-complete handler runs, and frames go out back-to-back. The receiver reports that the last two bytes of nearly every frame are corrupted while the first 62 are intact. What is the correct fix?
MCQ-21A driver on a non-coherent ARM64 SoC (Cortex-A53, 32-byte cache lines) hands a 100-byte receive buffer to a DMA engine, then reads the buffer after the transfer-complete interrupt fires. The buffer is 4-byte aligned, so it spans four cache lines: bytes 0-27 in line 0, 28-59 in line 1, 60-91 in line 2, and 92-99 in line 3. Before the transfer the driver calls the platform's cache-clean helper on the buffer, and after the interrupt it calls the cache-invalidate helper on the same range. Under load the driver intermittently reads stale bytes in the first 28 bytes of the buffer while the last 8 bytes are always correct. What is the most likely cause?
MCQ-23A 64-byte telemetry frame is sent from a sensor over UART at 115200 8E1 to a gateway. The gateway writes the frame to flash, then forwards it over I2C to a display controller. Field returns show about 1 in 10,000 stored frames has one byte changed, but the UART parity-error counter is 0 and the I2C master never sees a NACK. What should the team conclude and do?
MCQ-22A client library wraps `POST /charge` and retries once when a request times out. The library builds the `Idempotency-Key` header inside the retry loop, so each attempt sends a fresh UUID. The server keeps a unique index on that header and, when it sees a key it has already processed, returns the stored response instead of charging again. A charge request commits at 900 ms, but the response is lost in transit; the client's 1 s timeout fires and the library sends the retry. How many charges does the account see, and why?