2
\$\begingroup\$

I'm wiring an MPU 9250 in an SPI bus, and according to datasheet, the same pin as I2C SDA is SPI SDI:

enter image description here

Which leads me to think that since this is Data Input in the slave (MPU9250), would be equivalent to MOSI.

Wiring diagram in the datasheet seems to confirm this:

enter image description here

However, I was reading the SPI page on wikipedia (Ok, not the greatest source) and it says:

The MOSI/MISO convention requires that, on devices using the alternate names, SDI on the master be connected to SDI on the slave

Which confused me a bit. In the diagram, SDI is wired with SDO and naming is relative to the device the pin is in, which contradicts wikipedia (SDI naming is always relative to the master).

So, in essence, is the Wikipedia article wrong? Can I trust my assumption that SDI on the MPU = MOSI?

\$\endgroup\$
  • \$\begingroup\$ The french page for SPI on Wikipedia seems to be a direct translation but says the opposite: SDI should be connected to SDO. So one of the Wikipedia pages have to be wrong! \$\endgroup\$ – pserra Dec 17 '17 at 4:57
4
\$\begingroup\$

Devices other than MCUs having SPI interface tend to use SDI/SDO or DIN/DOUT convention (e.g. ADC/DAC chips, digital potentiometers, sensors etc). But MCUs always (maybe there are exceptions but I've never faced one) use MOSI/MISO convention (MSP430 series MCUs have a slight difference at this point: They have SIMO/SOMI pins which are totally the same as MOSI/MISO). This is because the MCUs are assumed (which should be) to be master.

NOTE: If two MCUs are communicating through SPI then the "master" tag alternates between the two (i.e. sender becomes "master" at the time), but the connection does not change: MOSI on the 1st chip connects to MISO on the 2nd chip and vice-versa.

Anyway, SPI data pins are not bi-directional buffers, so SDI pin on one chip should always be connected to SDO (or MOSI) pin on the other chip.

So,

  • The statement you've quoted from WP is totally wrong. SDI on a chip be connected to SDO on the other chip, regardless of whichever is assumed to be master or slave.
  • As I stated in the explanation above, SDI on the MPU9250 be connected to MOSI (master's out - slave's in) on the microcontroller/microprocessor.
\$\endgroup\$
1
\$\begingroup\$

Yep, SDI on slaves goes to SDO on master, but there is a trap in that naming convention that bit one of our contractors.

If you name the nets SDI and SDO then there is an ambiguity at either the master or the slave as one or the other must cross connect relative to the pin names, combine with a (ex)contractor who was rather lacking in attention to detail and nets mostly buried inside a 6 layer board... Oh how we laughed.

MOSI and MISO are far superior as names (especially for the pcb nets) as they are unambiguous at least in the common single master case, and this is now written into our schematic style guide.

\$\endgroup\$

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.