10
\$\begingroup\$

I'm working on a design that has a CPU with only one SPI port. I have multiple (3) slaves connected to this port, one of which is a microSD card.

Here is a report from an engineer who says that SD cards are designed to operate as the only slave to an SPI master.

Has anyone else been able to use a microSD along side other SPI slaves on the same bus? Perhaps this report was just based on a particular, problematic miniSD card?

Would anyone recommend gating the SPI CLK line with the Slave Select line that goes to the miniSD card, just to be safe?

\$\endgroup\$
12
\$\begingroup\$

According to this page SD cards drive and or release the DO line synchronously with the sclk line:

In the SPI bus, each slave device is selected with separated CS signals, and plural devices can be attached to an SPI bus. Generic SPI slave device drives/releases its DO signal by CS signal asynchronously to share an SPI bus. However MMC/SDC drives/releases DO signal in synchronising to the SCLK. This means there is a posibility of bus conflict with MMC/SDC and any other SPI slaves that attached to an SPI bus. Right image shows the drive/release timing of the MMC/SDC (the DO signal is pulled to 1/2 vcc to see the bus state). Therefore to make MMC/SDC release DO signal, the master device must send a byte after CS signal is de-asserted.

So just sending a dummy byte to the SPI after raising the CS line high should work. The site above has a timing diagram of the SPI bus when raising the CS line high on the SD card.

Also, it is a good idea to make sure that on power-up/card-insertion the microcontroller negotiates the use of SPI mode with the card. These details can be found here

In summary, it should be OK to share the SPI bus with multiple peripherals as long as the above precautions are taken.

\$\endgroup\$
  • \$\begingroup\$ Great resources, Justin. Thanks! I hope that will be all I need to do to handle slave conflicts with SD. \$\endgroup\$ – jpeskin May 21 '12 at 21:00

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.