Skip to content
Tech Interview Prep
Technical interview guide

Hardware-Software Co-Design & Peripheral Drivers

Writing drivers directly against a datasheet, using DMA to move data without the CPU, and the collaboration with hardware engineers that shapes firmware architecture.

Minutes to read
4
Practice MCQs
25
Interview Q&A
25
Edition
v4
Editorial status
Reviewed

Scope: Current Zephyr device/driver/devicetree/DMA/PM documentation and CMSIS-Driver 6/SVD/Core guidance reviewed 2026-09-04.

Overview

Curated: · Written: · Reviewed:

Hardware-Software Co-Design & Peripheral Drivers

In one line

Split each requirement between silicon, CPU and DMA, then check the split at the pins. Reach for it when a driver has a rate, deadline, power or safety requirement that the split must meet.

Key definitions

  • Effect chain: requirement, API call, register or bus write, physical effect, observable evidence. A break at any link is a bug.
  • Completion signal: the flag, interrupt or retired bus transaction the reference manual names as the end of the operation. An enable bit is not one.
  • W1C: write-one-to-clear. Writing 1 clears the bit; writing 0 leaves it unchanged.
  • Ownership handoff: the CPU owns a DMA buffer until it is armed, the DMA owns it until the TC flag, then the CPU owns it again.
  • Common-cause failure: a shared clock, reference or ADC channel that defeats both a function and its monitor.
  • Latency vs jitter: latency is hardware event to first handler instruction; jitter is what breaks a deadline.

Formulas and complexity

Interval between FIFO-full interrupts, 8N1 (10 bits per byte):

t=NFIFO×10fbaudt = \frac{N_{FIFO} \times 10}{f_{baud}}

16-byte FIFO at 12.5 Mbaud: 16 x 10 / 12.5e6 = 12.8 µs. If the worst-case ISR takes 18 µs, the FIFO overflows, bytes are lost, and DMA becomes a requirement.

12-bit ADC LSB with a 3.3 V reference:

VLSB=3.34096≈805.7 μVV_{LSB} = \frac{3.3}{4096} \approx 805.7\ \mu V

A 1% reference error is 33 mV, about 41 counts.

How it works

Bring-up order: enable the clock, release reset, configure pin mux and registers, then enable the peripheral and its interrupts or DMA requests.

DMA receive: the CPU arms the buffer, the DMA writes it, the TC interrupt fires, a DSB orders the access, and the driver invalidates the RX range by address before reading it.

Clock on, reset released Pin mux and registers configured Arm DMA, clean TX by address DMA owns buffer TC interrupt, then DSB Invalidate RX by address, CPU owns buffer

Hypothetical worked case (figures assumed for illustration): SPI RX on an 84 MHz AHB clock. If the length is read 12 cycles after the enable write, that is 12 / 84e6 = 143 ns. If the DMA is still writing at that point, the length is stale. Moving the ownership change to the TC interrupt removes the race.

When to use and when not to

OptionChoose whenCost
Fixed-function logicFixed, high-rate or hard deadline; must run while the CPU sleepsSilicon area, no field fix without a respin
CPU / firmwareBehaviour changes across releases; low rateCycles, latency, power
DMABulk, regular transfer; CPU has other workBus contention, cache maintenance, a second completion model
Non-cacheable MPU regionDMA buffers where cache maintenance is unwantedSlower CPU access to the region

Traps interviewers probe

  1. Treating the enable bit or API return as completion. Fix: wait for the TC flag or IRQ, issue a DSB, then read the data.
  2. Read-modify-write on a status register. An ISR that sets a bit between the load and the store loses that event. Fix: snapshot once, decode, and clear with a single write of the handled bits.
  3. Freeing or reusing a DMA buffer before completion. Fix: free it from the completion path, never after polling a few bytes.
  4. Invalidating RX after the CPU has touched the buffer. That discards the CPU's own writes. Fix: clean TX before the transfer, invalidate RX before the read, both by address; or map the region non-cacheable.
  5. Monitor sharing a reference or ADC channel with the function. Fix: give the monitor an independent channel and reference and, for high integrity, its own comparator path.

Interview tips

Open by naming the effect chain and the completion signal before any register. Then give the requirement, the split, and the evidence: a scope capture on the pin and the logged length at completion.

Expect these follow-ups:

  • How do you know the transfer completed? TC flag or IRQ, then DSB, then invalidate.
  • What if the ISR is late? Show the arithmetic against the FIFO interval.
  • Where does cache maintenance go? Clean TX before, invalidate RX before the read, by address.
  • How do you test it? Unit models, bus models, HIL, fault injection, scope trace; state the fidelity of each.
  • What is the errata process? Read the revision ID, branch to the matching sequence, and fail closed on unknown revisions.

30-second outline: "The requirement is X. Silicon does Y, the CPU does Z, and DMA moves W. Completion is the TC flag, then a DSB, then an address-based invalidate before the read. I prove it with a scope on the pin and a logged length at completion. If the ISR is late, the FIFO fills in 12.8 µs and bytes drop."

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.