0
\$\begingroup\$

Searching for images of SPI wiring between Master and Slaves, I found that some of them connect MOSI/SDI of master to MOSI/SDI of slaves and so MISO/SDO of master with MISO/SDO of slaves, meanwhile others connect them as MOSI/SDI to MISO/SDO and MISO/SDO to MOSI/SDI. There's someone that can me explain when there is the difference?

P.s. I'm working with PICs and I'm trying to drive a LED IC controller, but I'm mostly looking for a generic answer.

\$\endgroup\$
4
\$\begingroup\$

SPI pin names are intended to be unambiguous, regardless of which end (master/slave) you're looking at. Compare to something like "TX" and "RX" -- Transmit and Receive, respectively -- "Transmit from whose perspective?"

SPI pins are abbreviations:

  • M = "Master"
  • S = "Slave"
  • I = "IN"
  • O = "OUT"

So MISO = "Master In, Slave Out". It's an input of the master and an output of the slave.
Similarly, MOSI = "Master Out, Slave In". It's an output of the master and an input of the slave.

Some name pins differently, with "SDO" meaning "Serial Data Out" and "SDI" meaning "Serial Data In". This In/Out direction is from the perspective of the device in question.

So if both sides have "MOSI" and "MISO", connect "MOSI" to "MOSI" and "MISO" to "MISO".

If a slave has "SDI," connect that to "MOSI". And connect "SDO" to "MISO".
If a master has "SDI", connect that to "MISO". And connect "SDO" to "MOSI".

Don't glance over it too quickly like I did at first. Mixing naming conventions is dangerous business.

\$\endgroup\$
  • 2
    \$\begingroup\$ Is that how SDI is used? I thought SDI and SDO were like Tx and Rx, and stood for "serial data in" and "serial data out". \$\endgroup\$ – Hearth Feb 6 at 20:06
  • \$\begingroup\$ @Hearth you're right, and I must have been thinking of a different naming convention. I'll revise my answer. The Question merged the two names "MOSI" and "SDI", which shouldn't be the case for both Master and Slave. \$\endgroup\$ – Kevin Kruse Feb 6 at 20:10
  • \$\begingroup\$ @MicheleGiglio please see my edit. Mixing MOSI/MISO with SDI/SDO shorted something in my brain. The updated Answer is corrected now. \$\endgroup\$ – Kevin Kruse Feb 6 at 20:14
  • \$\begingroup\$ This definitely remove all doubts ^^✌️🏻 \$\endgroup\$ – Michele Giglio Feb 6 at 20:24
  • 1
    \$\begingroup\$ Also, top tip but when assigning net names in the CAD system, use MOSI/MISO and NEVER SDI/SDO, we had a 'attention to detail challenged' contractor hook all the SDI pins together once (Master and Slave), sweary that was (And another name went in my little black book). \$\endgroup\$ – Dan Mills Feb 6 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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