SPI Overview


PHPoC provides Serial Peripheral Interface (SPI) as one of methods to communicate with other serial device.

SPI Connection

SPI requires 4 signal lines between a master and a slave.

SPI Signal Lines

Label Name Description
SCK Serial Clock clock for synchronization
MOSI Master Output, Slave Input master's transmission line
MISO Master Input, Slave Output slave's transmission line
SS Slave Select master's slave select line

SPI connection

spi_overview_01

Selecting a Slave

A master's three lines except for SS are commonly connected to all slaves while SS is separately connected to individual slave. Therefore, a master which has three slaves should have at least three SS ports. To select a slave, the master outputs LOW to the line which is connected to the slave and output HIGH to the other lines. That means a master can communicate with a single slave at a time. After finishing communication, the master outputs HIGH to the line.

Data Communication

SPI Modes

There are four SPI modes (0 ~ 3) according to the sampling methods.

spi_overview_02

Bit Transmission Order

A master and a slave should be set to have the same bit transmission order. There are two ways: One is to send LSB first and the other is to send MSB first.

Transmission Sequence

Data buffer of a master and a slave has a type of ring buffer. Thus, sending and receiving data are simultaneously implemented at all times. The following figure shows data flow in case of sending LSB first.

spi_overview_03