Learning Rooms/□ Level 4 · Systems Engineer/Electronics
SPI: The serial peripheral interface
Ben Eater · 32 min 59 s · captions on YouTube · nothing loads until you press play
By the end you can…
- Read an SPI transaction from a timing diagram.
Watch it all: no segment has been checked by hand for this video yet.
1.Predict before you press play
A controller wants to read one byte from an SPI sensor. What must it do on MOSI while the byte arrives on MISO?
Pick one before you press play. A wrong guess is fine: it is what makes the video stick.
2.See the idea first
Play with this diagram for a minute. It gives you something to hang the video on.
Loading the interactive…
Can't use the diagram? Read a description instead
The SPI diagram shows two 8-bit registers. Starting with the controller holding 0x9F (10011111) and the peripheral holding 0x3C (00111100), each press of Clock once shifts both registers left by one: the controller's top bit goes into the peripheral's bottom bit over MOSI and the peripheral's top bit goes into the controller's bottom bit over MISO. After 8 clocks the controller holds 0x3C and the peripheral holds 0x9F: the bytes have swapped.
3.Watch, actively
Probes a real SPI bus with a logic analyser so you can see clock, data and chip-select line by line.
32 min 59 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
Watch for…
- → Watch the chip-select line go low before the clock starts, and notice data moving in both directions on every clock.
Pause whenever you like. Rewatching a hard minute is a good habit, not a failure.
Can't stream it? Read the idea instead
SPI uses a clock line, a data line in each direction and a chip-select line per device. On each clock edge one bit goes out and one comes in, so bytes are swapped in both directions at once. With no addresses to send, it is simple and fast, but needs an extra wire for every device.
What the video covers (our own note, written when we verified it): Probes a real SPI bus with a logic analyser so you can see clock, data and chip-select line by line.
Written by Tactiverge in our own words, not a transcript. The full lesson below explains the idea without the video.
Read it instead
- Lesson: SPI: swapping bytes at full speed · The full lesson explains the idea in text, worked examples and diagrams, with no video needed.
- Engineering Atlas: Serial communication: UART, I2C and SPI · A robot's microcontroller typically reads its motion sensor over I2C or SPI and talks to a larger computer over a serial link.
- Field Guide: Exceptions: try and except · A short reference entry on the same idea.
Jot down one thing that surprised you and one question you still have.
4.Practise what you just saw
These come from the lesson that use this video and are checked on the server. Wrong answers get a hint and another try.
Practice 1
Why does a controller send 0x00 on MOSI while reading a byte from an SPI sensor?
Practice 2
What is the maximum SPI data rate at an 8 MHz clock, in bytes per second?
Practice 3
Which bus suits a colour display that needs about 1 MB/s, on a board with pins to spare?
Practice 4
Four SPI peripherals share SCLK, MOSI and MISO, each with its own chip select. How many microcontroller pins does the SPI bus use?
5.Try it yourself
No simulation models this idea yet. The lesson below has an interactive diagram instead.
6.Where engineers use it
A 240 × 240 display at 16 bits per pixel holds 115 200 bytes per frame. At an 8 MHz SPI clock (1 MB/s) one full frame takes about 0.115 s, so roughly 8 frames per second; drawing only the part of the screen that changed is how small gadgets feel smooth.
From the applied view in the lesson SPI: swapping bytes at full speed. Checked by automated tests only.
7.Build something with it
Follow-up project
Plan the buses for a rover with a GPS (UART, 9600 baud), an IMU and a barometer (I²C), and a 160 × 128 colour display at 16 bits per pixel. How long does one full display frame take over SPI at 8 MHz, and how many pins do all the buses use together?
Draw the four SPI lines for sending one byte.
Where this video lives
- SPI: swapping bytes at full speed · Level 3, week 30
In the course catalogue: ECE-310 Embedded communication
The video is by Ben Eater, embedded from YouTube with privacy-enhanced mode and never autoplayed. The room around it (prompts, notes, practice, projects) is Tactiverge's, written with AI assistance and checked by automated tests only.