SPI Clock Calculator
Compute the SPI bus clock from the system clock and a clock divider.
Formula
SCK = Fsys / divider
Inputs
- System clock (Hz)
- Clock divider
What it does
The SPI clock (SCK) is the system clock divided by a prescaler: SCK = F_sys / divider.
Where it's used
Setting SPI speed for displays, SD cards, flash memory and sensors.
How to use it
- Enter the system (or peripheral) clock.
- Choose the divider.
- Compare SCK with the slave device’s maximum.
The formula explained
- SCK
- SPI clock frequency
- F_sys
- clock feeding the SPI peripheral
- Divider
- usually a power of two
Worked example
An STM32 at 72 MHz with ÷8.
Inputs:
- System clock: 72M Hz
- Clock divider: ÷8
The calculator gives:
- Result: 9 MHz
Tips and common mistakes
- Never exceed the slowest device’s maximum SCK on a shared bus.
- Long wires and breadboards limit reliable speed — slow down if data corrupts.
- SD cards must start at 400 kHz or less during initialisation.
Questions people ask
What are SPI modes 0–3?
They set the clock’s idle level (CPOL) and which edge samples the data (CPHA). Mode 0 — clock idles low, data sampled on the rising edge — is the most common. The device’s datasheet states which mode it needs.
Why can I only choose powers of two?
Many microcontrollers, STM32 included, build the SPI clock with a simple prescaler of ÷2, ÷4 … ÷256. If you need an exact rate, change the system or peripheral clock instead.
How fast can an SD card run over SPI?
Initialise it at 400 kHz or less, then switch up to 25 MHz (default-speed mode). Keep wires short; most corrupted SD transfers come from long or loose wiring.
Related Embedded & Comms calculators
Enter your values to get the result with the formula, substituted values and an explanation of each step.