When a microcontroller interface fails, firmware is often blamed first. Yet many “software” communication bugs are actually wiring, voltage-level or timing problems. The fastest diagnosis is to stop treating the interface as an API and inspect it as an electrical waveform.
First question: do the two devices share the same electrical assumptions?
Before decoding packets, verify:
- common ground;
- logic-high and logic-low voltage compatibility;
- whether the line is push-pull, open-drain/open-collector or tri-stated;
- required pull-up/pull-down resistors;
- idle polarity;
- connector pin numbering and cable orientation.
A correct register configuration cannot fix a 5 V signal connected to an input that is not 5 V tolerant.
I²C: the pull-up is part of the timing
I²C SDA and SCL are shared lines whose high level is created by pull-ups rather than a normal push-pull high drive. That means pull-up resistance and total bus capacitance affect rise time.
The NXP I²C specification defines rise/fall times and setup/hold requirements for the different bus modes. If the waveform rises too slowly, a bus can fail even when the configured clock frequency looks correct in firmware.
With an oscilloscope, inspect the actual high-level rise. With a logic analyzer, check START/STOP conditions, acknowledgements and whether one device stretches or holds the clock unexpectedly.
SPI: match mode and chip-select timing
SPI failures frequently come from clock polarity/phase mismatch, wrong bit order or chip-select behavior. Do not rely only on labels such as “Mode 0” from memory; verify the peripheral’s timing diagram.
Capture SCLK, MOSI, MISO and CS together. Ask:
- Which clock edge changes data?
- Which edge samples it?
- Is CS asserted for the complete transaction?
- Does the target require setup time after CS before the first clock?
- Does MISO actually release when CS is inactive?
UART: baud rate is only one variable
For UART, confirm baud rate, data bits, parity and stop bits, but also measure the idle voltage and bit period. A wrong oscillator assumption can create a baud-rate error even if both source files say “115200.”
Swapped TX/RX, missing ground and inverted-level interfaces are still common. Also distinguish logic-level UART from standards such as RS-232 or RS-485; they are not electrically interchangeable just because the payload is asynchronous serial data.
Long wires turn digital interfaces into analog problems
As edge rates increase, wiring inductance, capacitance, return-path geometry and reflections matter. A low nominal clock frequency does not guarantee slow signal edges.
When a bus works with a 10 cm jumper but fails through a long cable, reduce wiring length, improve the return path, check termination/source damping where appropriate, and inspect the waveform with an oscilloscope. A logic analyzer may decode a corrupted edge without showing why it is corrupted.
Do not overload the bus with probes and devices
Every device, cable and probe adds electrical loading. On I²C this directly affects capacitance and rise time. On faster push-pull interfaces it can degrade edges and increase ringing.
If adding a logic analyzer changes whether the circuit works, that is useful evidence: the system likely has marginal signal integrity or biasing.
A disciplined measurement workflow
- Confirm pin mapping against the schematic and MCU alternate-function table.
- Measure idle voltages before any transaction.
- Capture one short known transaction.
- Measure clock/bit period.
- Measure setup and hold around the sampling edge if the interface is marginal.
- Check rise/fall behavior with an oscilloscope when analog edge quality matters.
- Reduce bus speed and wiring length as controlled experiments.
- Change one variable at a time.
Use the protocol decoder as a helper, not proof
A decoder is excellent for identifying addresses, commands and missing ACKs. But it operates after thresholding the waveform. It may not reveal ringing, marginal voltage levels or slow edges. Always keep the raw waveform available when diagnosing an intermittent problem.
Timing bugs can originate in generated firmware
If the electrical waveform is clean but transactions are irregular under load, inspect interrupt latency, blocking loops, DMA ownership and clock configuration. Our guide Why Auto-Generated Embedded Code Can Still Fail on Real Hardware covers those software/hardware boundary failures.
Use the schematic review to prevent interface failures
Many problems can be caught before layout: wrong pull-up rail, missing level shifter, undefined reset states or unprotected external connectors. See How to Use AI to Review a Schematic Before You Build the PCB for a pre-layout review process.
Final checklist
| Layer | Evidence |
|---|---|
| Wiring | Pin-to-pin continuity and shared ground verified |
| Voltage | Idle/high/low levels measured and within device limits |
| Protocol | Configuration matches the target datasheet |
| Timing | Real bit/clock period and critical setup/hold measured |
| Signal integrity | Edges inspected when cable/loading/speed makes it relevant |
| Firmware | No unbounded blocking, ownership conflict or clock assumption |