SPI Comm

1 minute read

SPI

SPI is a simple interface that allows one chip to communicate with one or more other chips. It requires 4 wires to be used in between the two chips.

-Placeholder1-

The wires are called SCK, MOSI, MISO and SSEL, one chip takes the role of SPI master, while the other the SPI slave.

SPI fundamentals

  • Synchronous: a clock is generated by the master.

  • Full-duplex serial: data is serialized, one bit of data is transferred in each direction during each clock period, so two data wires are used (MOSI and MISO).

  • Not plug-and-play: The master and slave know beforehand the details of the communication (bit order, length of data words exchanged, etc…).

  • One master: slave(s) cannot initiates communication, only the master can. The slave(s) listen and respond.

Simple transfer

Let’s assume that the master and slave expect 8-bits data transfers, with MSB transmitted first. Here’s how would look a single 8-bits data transfer.

-Placeholder2-

The line MOSI is the “master output” while MISO is the “slave output”. Since SPI is full-duplex, both lines toggles simultaneously, with different data going from master-to-slave, and slave-to-master.

In more details:

-Placeholder3-

  • The master pulls SSEL down to indicate to the slave that communication is starting (SSEL is active low).
  • The master toggles the clock eight times and sends eight data bits on its MOSI line. At the same time it receives eight data bits from the slave on the MISO line.
  • The master pulls SSEL up to indicate that the transfer is over.

If the master had more than one 8-bits data to send/receive, it could keep sending/receiving and de-assert SSEL only when it is done.

Multiple slaves

An SPI master can communicate with multiples slaves in two ways: by connecting most signals in parallel and adding SSEL lines, or by chaining the slaves.

-Placeholder4-

With the multiple SSEL lines technique, only one SSEL line is activated at a time, and slaves that are not selected must not drive the MISO line. SPI can easily achieve a few Mbps (mega-bits-per-seconds). That means it can be used for uncompressed audio, or compressed video.

Links

(The Serial Peripheral Interface Bus from Wikipedia)[https://en.wikipedia.org/wiki/Serial_Peripheral_Interface]