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
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.
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
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.
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.
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.
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.
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
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.