SD readers/Speed, measured/08. Four wires, one clock
Speed, measured · 08 of 11

Four wires, one clock

Four data lines carry a byte in two clock ticks instead of eight, and buy about forty per cent. The rest goes on a demand the wider bus makes and the narrower one does not: four signals arriving at one clock edge together.

Two ticks instead of eight

One byte across the bus
1 data line
Data lines
Clocks per byte
8
On the bus
1 bit a tick
Measured read
2.67 MB/s
Four lines carry a byte in two clock ticks instead of eight. The bus is four times as wide, and at the same 40 MHz the measured sustained read went up 1.4× — not four. What the extra lanes cannot speed up is the card’s own flash, the command that precedes every transfer, and the filesystem work the ESP32 does between blocks.

The arithmetic is the easy part. One data line moves one bit per clock edge, so a byte takes eight. Four lines move four bits per edge, so a byte takes two.

The measurement is less tidy. At the same 40 MHz, the sustained read went from 2.67 MB/s to 3.80 MB/s — about forty per cent, not four hundred. What the extra lanes cannot speed up is the command that precedes every transfer, the card's own flash, and the filesystem work the ESP32 does between blocks.

What the wider bus demands

One data line only has to be right when the clock edge arrives. Four data lines all have to be right at the same clock edge, and anything that makes one wire different from its neighbours — a different length, a loose contact, a jumper that runs alongside the clock — eats into the window in which that is true.

This is not a theory. It is what the bench measured.

Finding a clock that works
full-size SD · 4-bit
Board
Clock settled at
26 MHz
Sustained read
3.40 MB/s
Steps tried
2
40 MHz failed its write check and the driver dropped to 26 MHz, which cost about 11% of the read speed the other board reached. Both boards carry the same 22 Ω series resistors and the same pull-ups, so the difference is not the board. It is six jumper wires of unequal length being asked to stay in step at one clock edge. Shorter wires, cut to the same length, with a solid ground beside them, and this step usually goes away.

The two boards are the same circuit with the same 22 Ω series resistors and the same 10 kΩ pull-ups. One settled at 40 MHz and the other at 26, on the same card on the same day, and the difference was six jumper wires.

What to do about it

  • Make the ground wire as short as the signal wires. Every edge is measured against it.
  • Cut the four data wires to the same length, not merely to a short one.
  • Keep the clock away from the data lines where you can, rather than running all six in a neat ribbon.
  • If the driver keeps dropping the clock, ask for a lower one on purpose. A reliable 20 MHz beats a 40 MHz that fails its write check.

Or wire three signals instead of six and take 1-bit mode, which has no simultaneity problem at all and gave up about a third of the read speed for it.

When it does not work

4-bit mode is slower than 1-bit on my bench

Then the driver has stepped the clock down. It tries 40 MHz first and drops through 26, 20, 10, 4 MHz and finally 400 kHz, verifying a 1 MB write at each step, so a bad set of wires turns into a low clock rather than an error. Print the frequency it settled on before you blame the mode.

It mounts at 400 kHz and nothing else

That is the probe speed — the frequency a card is talked to before it has agreed to anything — and landing there is a wiring diagnosis, not a card diagnosis. Shorten the six wires, cut them to the same length, and make sure the ground wire is as short as the signals.

Which wire should I shorten first?

The ground, then the clock. Every data line's edge is measured against ground, so a long, thin ground wire shared by six signals is the one that makes all six worse at once. After that, keep the four data lines the same length as each other rather than merely short.

Can I just run 4-bit at a lower clock on purpose?

Yes, and it is often the right answer on a breadboard. SD_MMC.begin() takes a frequency, so asking for 20 MHz and getting it reliably beats asking for 40 and having the driver decide for you after a failed write.

Where this goes next

Six wires, a sketch that writes a line and reads it back, and what the serial output should say.

Your first file, over SPI

Edit this page — content/books/sd/four-wires-one-clock.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum