Communication Guide
SPI Timing Budget: Clock, Data, Chip Select, and Board-Level Verification
A valid SPI divider and transfer-time estimate do not prove that either end samples stable data. Close the physical timing path from clock launch to data capture, then validate it on the assembled board.
18 min · Intermediate · Updated October 17, 2026
Start with the Actual Devices
Record controller peripheral clock and divider choices, peripheral SCLK maximum, input setup and hold requirements, output clock-to-data delay, CS setup and hold times, supply range, temperature range, and whether MISO releases when deselected. The SPI Clock Calculator converts a divider to fSCLK, bit time, and ideal block transfer time. It does not calculate setup, hold, PCB propagation, or analog edge quality.
| Timing quantity | Read from | Why it matters |
|---|---|---|
| SCLK period and duty | Controller output and peripheral AC tables | Sets available launch-to-sample interval |
| Output delay | Transmitter maximum tCO | Data is not valid immediately at clock edge |
| Input setup/hold | Receiver AC table | Required stable window around sample edge |
| CS setup/hold | Peripheral timing diagram | Command state and first/last bit validity |
| Board delay/skew | Trace or cable model and measurement | Clock and data arrive at different times |
Map the Launch and Sample Edges
CPOL sets the idle clock level; CPHA selects which edge shifts and which samples. Confirm the controller and peripheral use the same interpretation. For a common Mode 0 transfer, data is captured on a rising edge and changes on a falling edge. Another mode can move the first-bit requirement or the available interval. Draw one timing diagram for MOSI and another for MISO using the chosen devices, not a generic SPI label.
A controller can meet its own pin timing yet fail at a distant peripheral after clock/data skew. Conversely, the return path adds an outbound clock flight and an inbound MISO flight. Do not combine minimum and maximum numbers from different voltage or temperature conditions without a documented corner assumption. See the Serial Interface Guide for high-level protocol comparisons; this page owns physical SPI timing closure.
Budget the MISO Return Path
For a specific opposite-edge launch/sample arrangement, an illustrative MISO setup budget is half the SCLK period minus outbound clock flight, peripheral clock-to-output maximum, return data flight, controller input setup, and an explicit uncertainty allowance. Verify the actual edge relationship and device timing definitions first; some controllers provide a delayed sample or a different phase relationship.
Formula reference
Illustrative opposite-edge setup budget
T = 1/fSCLKMsetup ≈ T/2 - tclk,out - tCO,max - tMISO,return - tSU,master - tuncertaintyVariable definitions
- Only applies when a peripheral launches on one edge and controller samples the opposite edge
- tclk,out and tMISO,return are interconnect flight times
- tuncertainty reserves jitter, skew, edge variation, and model uncertainty
- Positive setup margin alone does not prove hold or signal-integrity compliance
At 20 MHz, T/2 = 25 ns. If outbound clock flight is 3 ns, peripheral tCO,max is 8 ns, return flight is 3 ns, controller setup is 4 ns, and uncertainty is 2 ns, the remaining illustrative setup margin is 5 ns. A longer route or a different sampling convention can consume it. Check hold with minimum clock-to-output and minimum flight times separately; the setup inequality cannot certify hold.
Include MOSI, CS, and Gaps
For MOSI, compare controller data launch with clock arrival at the peripheral and its input setup/hold specifications. Depending on route lengths, clock can arrive early or late relative to data. CS may need to assert before the first SCLK edge, remain active past the last edge, and stay inactive for a specified recovery interval before another command. Continuous SCLK time excludes command/address bytes, dummy clocks, CS gaps, firmware scheduling, DMA start latency, and device processing delay.
Formula reference
Transfer-time accounting
Tshift,ideal = Nbits/fSCLKTtransaction = TCS,setup + Tshift + Tgaps + TCS,hold + TsoftwareUseful throughput = Npayload bits / TtransactionVariable definitions
- Nbits includes every clocked command, address, dummy, and payload bit
- Tsoftware is measured or bounded firmware/DMA overhead, not an SPI electrical constant
- Full-duplex wires carry simultaneous bit streams, but useful response bytes may lag command bytes
For a 4-byte command/address phase plus 256 payload bytes at 20 MHz, uninterrupted shifting of 260 bytes takes 104 µs. If setup, hold, interburst, and firmware delays total 16 µs, the transaction is about 120 µs and useful 256-byte payload rate is about 17.1 Mbit/s, not 20 Mbit/s. Actual protocol direction and dummy cycles may reduce it further.
Check the Shared-Bus and Board Boundary
On a multi-peripheral bus, verify each device releases MISO when deselected and that no two CS lines overlap during configuration changes. Devices can require different CPOL/CPHA modes, SCLK ceilings, supply levels, or CS recovery intervals. Do not assume a level shifter preserves timing or edge shape; include its propagation delay and output-drive behavior. Route clock with a continuous return path, control stubs and ringing, and measure at the receiving pins. Series damping, if needed, is a board-specific signal-integrity decision, not a universal resistor value.
Verification Matrix
| Test | Measure | Expected evidence |
|---|---|---|
| SCLK and mode | Idle level, edge order, duty cycle | Matches each selected peripheral |
| MOSI | Data stable at peripheral sample edge | Setup and hold across corners |
| MISO | Data stable at controller sample edge | Clock round trip and tCO included |
| CS | Assertion, hold, inactive recovery | First and last bits correct |
| Multiple peripherals | Deselected MISO level and overlap | No contention or mode leakage |
| Signal integrity | Overshoot, undershoot, ringing, edge time | Valid input thresholds at receiving pins |
| End-to-end transfer | Payload, gaps, retries, CRC/status | Measured throughput and error rate |
Use a probe with suitable bandwidth and a short return path. Capture worst-case devices, longest routes, highest clock setting, and low/high supply plus temperature corners. A logic analyzer shows decoded traffic but may hide analog threshold or ringing failures; pair it with an oscilloscope when timing margin is small.
Common Mistakes
- Equating divider-derived SCLK with guaranteed link speed.
- Using the wrong CPOL/CPHA mode or first-bit convention.
- Budgeting MISO without outbound clock and return data delay.
- Checking setup but not hold.
- Using typical tCO instead of a valid maximum corner.
- Ignoring CS setup, hold, and deselected recovery.
- Counting payload bytes but not command and dummy clocks.
- Assuming SCLK/8 is sustained useful throughput.
- Ignoring level-shifter delay or MISO bus contention.
- Measuring only at the controller pin rather than the receiver.
- Treating a clean decoded capture as proof of analog margin.
- Applying the illustrative half-cycle equation to every SPI mode.
Primary Engineering Sources
Consult Microchip SPI timing guidance for mode conventions and Microchip CS hold guidance for the importance of select timing. Verify numeric limits against the exact controller and peripheral datasheets.
Support reference
FAQ
What limits SPI clock speed?
The weakest controller, peripheral, board, voltage, and temperature corner sets the limit. Setup and hold windows, output delay, routing, and signal integrity can matter before the nominal SCLK maximum.
What do CPOL and CPHA change?
They select clock idle level and which clock transition shifts versus captures data. Both ends must agree on the mode and the timing diagram must match the selected device.
Is half a clock period always available for SPI data?
No. A half-period model is common for a device that launches on one edge and samples on the opposite edge, but actual device phase, internal delay, sample point, and controller behavior can change the budget.
Why is MISO often the critical path?
The controller clock travels to the peripheral, the peripheral responds after clock-to-output delay, and MISO travels back to the controller before its sample edge.
Does the SPI Clock Calculator include board delay?
No. It calculates divider-derived SCLK and ideal transfer time. Use the device timing tables and measured or modeled interconnect delay for setup and hold closure.
How is payload throughput different from SCLK/8?
SCLK/8 is an uninterrupted eight-bit transfer ceiling. Commands, addresses, dummy cycles, chip-select gaps, DMA or firmware latency, and response turnaround lower sustained useful throughput.
How should chip-select timing be checked?
Verify the peripheral minimum CS assertion-to-first-clock, final-clock-to-deassertion, and deselected recovery intervals under the controller's actual register and firmware behavior.
What changes with multiple SPI peripherals?
Devices may require different modes, clock limits, CS timing, voltage levels, or MISO high-impedance behavior. Reconfigure and test each selected device and bus contention corner.
Can slowing SCLK solve every SPI failure?
It can improve some setup margin, but cannot fix wrong mode, insufficient hold, CS sequencing, overshoot, level mismatch, or a peripheral that keeps driving MISO while deselected.
Summary
Use the clock calculator for SCLK and ideal shift time. Close the chosen device pair's MOSI, MISO, and CS timing with min/max corner data, board delay, and measured signal integrity before claiming a reliable transfer rate.
