SPI Clock Calculator

Compute the SPI bus clock from the system clock and a clock divider.

Formula

SCK = Fsys / divider

Inputs

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

  1. Enter the system (or peripheral) clock.
  2. Choose the divider.
  3. 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:

The calculator gives:

Tips and common mistakes

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.

All engineering calculators