Serial Peripheral Interface

From Stm32World Wiki
Jump to navigation Jump to search
Winbond W25Q128 mounted on a Black Pill board

SPI is a synchronous serial protocol, like I²C but with separate lines for transmit and receive and a Chip Select signal (on SPI sometimes called SS for Slave-Select) to indicate the active device. Each SPI bus will have one master and one or more slaves (selected by the CS line). Compared with other synchronous serial protocols such as I2C, all the lines on a SPI bus are driven in both directions and they can be much much faster (80 Mbps is possible although most STM32 MCUs will top around around 40 Mbps).

Single slave

SPI single slave.svg

The master, will begin a transmit on the MOSI (Master Out, Slave In) line but for reading, it will continue to provide clock which is then received on MISO (Master In, Slave Out) line.

Multi-drop

It is possible to have more than one SPI devices on a shared bus, but each device need it's own CS.

SPI three slaves.svg

Obviously, in this configuration, only one SPI device can be used at any time.