protocol spi

Resource In serial communication, bits are sent one by one through a single wire. Transmission of the letter “C” in binary

What is SPI Serial?

SPI is a communication protocol, commonly used in RFID modules or SD card readers. In SPI, data can be transferred without interruptions.

  • In I2C and UART, data is sent in packets, limited to a specific number of bits.

Devices that communicate via SPI are in a master & slave relationship. One master may control more than one slave.

Pin/Wire Configurations

MOSI - Master Output / Slave Input - line for master to send data to slave MISO - Master input/ Slave Output - line for slave to send data to master SCLK - Serial Clock SS/CS - Slave Select / Chip Select, line for the master to select which salve to send data to

How SPI Works

SPI communication is initiated by the master since it generates the clock signal. Any communication protocol where devices share the same clock signal is known to be synchronous. SPI is a synchronous communication protocol.

  • Slave select: the master can choose which slave it wants to talk to by setting the slave’s CS/SS level to a low voltage. the idle state is a HIGH voltage state (held by a pull-up resistor!)
  • MOSI & MISO: the master sends data to the slave bit by bit, through the MOSI line. the slave receives the data sent by the master through the MOSI Pin. Data sent from the master to the slave is sent with the MSB first.

Steps outlined:

  1. master outputs clock signal
  2. master switches SS/CS pin to low voltage, activating the slave
  3. master sends one bit at a time through the MOSI line

Advantages of SPI

SPI allows for continuous streams of bytes to be sent. There is no addressing system for slaves, and SPI is faster than I2C

Disadvantages of SPI

  1. uses 4 wires
  2. no ACK bit
  3. no error checking
  4. single master only