I am new to SPI. I am little bit confused about its working. I know that it is synchronous. Let's say I want to read a value at address. So the process would be: First master will send address byte. For each bits in address byte sent by master, slave will also send bits. What are those bits sent by slave? After Address bit is sent, slave send the value at that requested location. For each bit in Value byte sent by slave, Master also send some bits to slave. What are those bits. SPI works on shift register. Please correct me if I am wrong.

Please reply.


  • \$\begingroup\$ There is no addressing in SPI, slaves are addressed with slave select lines. Take five minutes and Google the protocol. If you're talking about a particular SPI part, you need to mention which one. \$\endgroup\$
    – Matt Young
    Jul 1, 2015 at 17:22
  • \$\begingroup\$ I agree there's nothing addressing mechanism in SPI.Its done by chipselect. But my question is once slave device has been selected, how the communication actually works. Let say, once Master shift the MSB to slave, the slave also shift the MSB to Master. What is that bit actually shifted from slave.? \$\endgroup\$ Jul 1, 2015 at 17:27
  • \$\begingroup\$ As often, there is only one answer: read the datasheet! (of the particular chip) You are kind-of asking what, according to the HTML protocol, a webserver will answer when you ask for index.html That is not defined by the protocol, it is one step above it. \$\endgroup\$ Jul 1, 2015 at 17:44

3 Answers 3


All bits to be sent or received are defined in the device's datasheet. The master sends one or more bytes and then continues to clock (optionally sending further bytes) in order to receive bytes from the slave. If the slave does not have any meaningful byte to send then it may send any byte it likes.


You are right! Since SPI is full duplex, and there is no way for either party to send 'nothing', there's always a lot of padding being sent in either direction.

Another very common protocol, which doesn't have this property is i2c.

  • 2
    \$\begingroup\$ Of course, when you're sending at 10MHz+ instead of 1.7MHz you usually aren't too worried about junk bits. \$\endgroup\$ Jul 1, 2015 at 17:45
  • \$\begingroup\$ There's no inherent reason for SPI to be duplex- some micros allow you to use (say) for output only and use what would be the the MOSI pin for something else. Useful if you're just outputting data to an MSI shift register or a DAC. \$\endgroup\$ Jul 1, 2015 at 20:27
  • \$\begingroup\$ Well, SPI is duplex in a way that i2c is not. I'm sure there are flavors of both SPI and i2c with different properties. That said, of course one of the lines can be left out if not needed and it's certainly possible to build useful SPI-circuits which are simplex. \$\endgroup\$
    – avl_sweden
    Jul 1, 2015 at 22:16

There are many microcontrollers that have hardware SPI protocol implemented. You can access it through right registers. But I always prefer implementing a software SPI. In software SPI you use simple GPIOs for implementing SPI within the code by referring to the timing diagrams. This will also help you to understand its operation better.

You can find the SPI timing diagrams below.

There are many ways of SPI communication: 1) MSB first, active to idle 2) LSB first, active to idle 3) MSB first, idle to active 4) LSB first, idle to active

where you can even play with defining the idle state whether low or high.

Keep these facts in mind while studying SPI.

enter image description here

enter image description here


Not the answer you're looking for? Browse other questions tagged or ask your own question.