Embedded System







SPI stands for Serial Peripheral Interface. As the name implies, this is mainly for communicating with other device (chipset or module) using a kind of serial communication.  Most common use case for this technology is connecting one master to one slave module as illustrated below. Like I2C, it uses a common clock called SCLK, but unlike I2C it uses two separate data lines for input and output. And it has another pin called SS which does not exist at all in I2C.



Even though SPI is designed mainly for Single Master and Single Server, it is doable to use it in single master and multiple slave as in BUS as illustrated below. However, the wiring gets much more complicated in this case.




Common Applications of SPI


Most common applications of SPI that I have found through surfing many pages on the web is to interface a board or Microprocessor to external memory. Since this kind of application would need relatively high data rate, SPI would be more suitable than I2C.



How far they can communicate over SPI ?


I haven't found any explicit answer from any formal document, but I have read through many pages on the web stating various numbers based on experience. Most common number seems to be around a couple of meters. It seems to me that the number seems to be smaller than I2C max distance.


Which one to choose : I2C or SPI ?


In most of the Embedded Board, you would find both I2C and SPI pins and then you would ask yourself which one to use.

The answer would be given partly by personal preference and partly by the nature of the application you want to implement. I think most important criteria you may think of would be as follows

  • Data Rate : If you need a communication system supporting in Mhz range clock (similar data rate), you would go with SPI
  • Complexity : If you don't need very high data rate (well under a Mhz) and want to get very simple technique (or less wiring), you would go with I2C.
  • Number of Slaves : Even though it is doable to control multiple Slaves with SPI, it would not be doable as easy as I2C



Reference :


[1] Serial Peripheral Interface (SPI)

[2] How do you use SPI on an Arduino?

[3] Tutorial: Arduino and the SPI bus