3

I am using a micro sd card shield with an arduino zero, and I am not sure I am using a proper circuit with it. This is the circuit I am using right now:

sd card circuit schematic That is all it is there, just a capacitor for the power and a pullup resistor for the chipselect. The tags just go to the processor.

I have seen a lot of schematics out there with resistors in series to the processor, some times with pull up resistors, some times with pulldown resistors...

I'm not sure the pullup resistor I am using is a good idea, and I am unsure about the value.

To me something like this makes more sense:

enter image description here

Can someone teach me a proper circuit for this? what is best and why?

Right now I am not very happy with the performance of the micro SD card socket. That's why I want to improve it.

EDIT: Turns out I didnt really understand very well the second schematic, it was just voltage dividers to lower the 5v os arduino uno to 3V. But what about the pullup resistor of the MISO?

3 Answers 3

4

As per the SD card specification:

When an SD card is operating in SPI mode or 1-bit SD mode, the CMD and DATA (DAT0 - DAT3) lines of the SD bus must be pulled up by 10 kOhm resistors. Slaves should also have pull-ups on all above-mentioned lines (regardless of whether these lines are connected to the host) in order to prevent SD cards from entering a wrong state.

Basically you need to ensure that "everything is off" until the Arduino actively drives the SD card. Without them the SD card's inputs will be floating and doing anything they like until the Arduino starts communicating.

Resistors in-line with the signals are there really just to increase the impedance and prevent damage when hot-swapping a card.

If you have a 5V Arduino you will require logic level translation. This is a separate thing to the resistors. While resistors are OK for UART or simple IO logic level translation they are not suitable for use with an SD card. This is because the clock frequencies involved are too high and the resistors will corrupt the signal (through low pass filtering). Instead you require an active logic level translation system, such as a dual voltage, or TTL input, buffer, or active MOSFET level shifters.

5
  • I think those are not a good idea. They are actually voltage dividers from 5V to 3V.
    – Espada86
    Jun 10, 2021 at 16:55
  • @Espada86 What are not a good idea? And what is a voltage divider between 5v and 3v?
    – Majenko
    Jun 10, 2021 at 17:17
  • Arduino UNO works with 5V, but SD Socket works with 3V. Thats the reason they put 3 voltage dividers.
    – Espada86
    Jun 10, 2021 at 17:30
  • @Espada86 Logic level translation is a completely separate issue. The resistors are still required even if you have level translation. And using resistors as logic level translation for SD cards is not practical - the frequencies involved are too high.
    – Majenko
    Jun 10, 2021 at 17:37
  • After a lot of testing and investigating it seems that the pullup resitor on miso is the key. I tried a lot of things and this one is the single thing that did the job for me. I finally managed to make it work in a reliable way. I am thinking about putting it on every SPI device connected. Do you think it is usefull to put pull up resitors on al lines? I mean miso, mosi, sck, and CS. Or just miso?
    – Espada86
    Jun 24, 2021 at 21:04
2

There's an excellent tutorial on Instructables I recommend one to read. here's the link https://www.instructables.com/Select-SD-Interface-for-ESP32/

enter image description here

1
  • 1
    Thanks for sharing that link, it is really usefull
    – Espada86
    Sep 30, 2022 at 14:55
1

There are a couple of "do and don't" when designing an SPI interface.

Do add pull-up resistors on SS or set SS HIGH for multiple-slave system

SPI is a bus system, means that your device might not be the only one using the interface. When designing an SPI interface, you therefore has to consider the scenario where multiple SPI devices are used, and especially when some of the slaves are not coded by your system.

Without a pullup resistor, the SS line might be neither LOW nor HIGH, this might caused some of the devices on the bus to “hear” the communication on its MISO that was not intend for the device. This might explained why some of the Arduino shields or breakout boards with SPI works when used alone, but fail when used together with other SPI boards, causing by some of those boards lack of pullup resistor or the user didn't pull the SS lines in the system HIGH at the setup() before calling the SPI.begin()!

Do ensure MISO can be tri-state in multiple-slave system

Most SPI chips will be at tri-state on their MISO pin (but there are some chips out there requires extra external tri-state buffer chip) when their chip select signal is HIGH. Tri-stage means that it is neither HIGH nor LOW (i.e. floated) and effectively disconnect. However, A SPI device without tri-state MISO could caused potential problem on a SPI bus where multiple SPI devices are connected. If the MISO is unable to be at tri-state, it will be either HIGH or LOW, this will affect other devices connected on the same bus in receiving data.

With this in mind, it is not a good idea to add a pull-up resistor on MISO line.

1
  • Noted, Thank you
    – Espada86
    Sep 30, 2022 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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