Skip to content

Latest commit

 

History

History
69 lines (44 loc) · 2.35 KB

File metadata and controls

69 lines (44 loc) · 2.35 KB

SPI Protocol

Features

  • Synchronous
  • Serial
  • Full duplex
  • Master-slave architecture
  • Single master multiple slave

Popular uses

  • For interfacing microcontrollers with sensors or other modules (SD cards, EEPROMs, etc)

Interface

  • One clock pin
    • SCLK : Sent by master to slaves
      • Data is sample on the rising edge of clock
  • 2 data pins
    • MOSI : Master Out Slave In
    • MISO : Master In Slave Out
  • Select pins for each slave
    • SS : Slave select (Active LOW)
  • Any number of bits can be sent or received - no concept of packets

Often, peripheral devices call MOSI as SDI (Serial Data In) and MISO as SDO (Serial Data Out), and Slave select as CS (Chip Select)

Note : Most of the time, chip select is not a part of the SPI hardware interface and is controlled using other GPIO pins.

Protocol

The SPI protocol is implemented using shift registers.

So, the SPI protocol acts like a ring buffer in this case. The slave buffer is read by the controller when CS pin goes high.

Multiple slaves and daisy chaining

Using multiple slaves with seperate slave select pins SPI multiple slaves

If we are short on pins, and since we know that the slaves use shift register, we can use "daisy chaining" with a single pin. The shift register values are only read when CS pin goes high. So, in the case below, we can maintain CS pin low for transferring 3 words which are shifted over one-by-one. We need to send the word to the last slave in the chain first.

SPI daisy chaining


Block diagram

Testbench block diagram

Daisy block diagram

Results

Daisy chaining waveform


References

  1. CircuitBasics
  2. MaximIntegrated
  3. ADXL345 Accelerometer
  4. MAX5295 DAC
  5. AnalogDevices