Showing posts with label embedded systems. Show all posts
Showing posts with label embedded systems. Show all posts

Thursday, October 30, 2014

Compare I2C and SPI protocols.


  • SPI protocol requires more hardware(I²C needs 2 lines and that’s it, while SPI formally defines at least 4  Signals).
  • SPI procol is faster than I2C, it works in full duplex mode, can transmit upto 10Mbps whereas I2C is limited to 1Mbps in normal mode and 3.4Mbps in fast mode.
  • SPI can have only one master whereas I2C supports more than one masters.
  • In SPI there is no limitation to the number of bits transmitted in one frame(I2c 8bits).
  • SPI is non standard whereas I2C is standard protocol.

Read these two posts for better understanding 

SPI Protocol

SPI(Serial Peripheral Interface) is a single master multiple slave serial transmission protocol that works in full duplex mode.



  • There can be only one master but there can be multiple slaves.
  • MOSI- Master out Slave In
  • MISO- Master In Slave Out
  • SCLK- Clock Signal
  • SS or CS- Slave Select or Chip Selecthe 
  • The data is transmitted using shift register.
  • With the number of clocks equal to the word size(generally 8) the master and slave would have exchanged the value in their shift register.
  • They can now process the data they have received or/and can load new data in the shift register.



Lets Talk Business and Discuss The actual Protocol

  • To start off , the the master configures the clock rate of transmission(frequency should be less than the maximum supportable frequency).
  • The master then sends a chip select signal 0 on the chip select line which it wants to choose.
  • Since the lines are active high so by default they are high(initially).
  • Sometimes a waiting time is involved, so the master must wait for that duration before it starts the clock cycle.
  • During each SPI clock cycle a full transmission happens with this operation-
  1. The master sends one bit on MOSI line and the slave reads on the same line.
  2. The slave sends one bit on the MISO line and the master reads on the same line.
  • We may not need all these transmission for our purpose but as per the protocol this has to happen.