2
\$\begingroup\$

I am attempting to write data to a SD card from a ATmega328P micro controller with no luck. I've narrowed down the source of the problem to the MISO output of my SD card breakout board, which doesn't seem to be able to pull up all the way to 3.3V. This is plain to see on an oscilloscope:

enter image description here

In the image above, the SD card is attempting to respond to the master with 0xFF. However, it can only pull up to about 500mV. Below is the clock signal, which I used as a sanity check to verify the oscilloscope was working.

enter image description here

My question is: What could be the source of this problem? I feel as though the answer is staring me right in the face. Perhaps I should take a break and come back with a fresh pair of eyes.

Hardware:

  • 16 GB SD Card - TS16GSDHC10E
  • Sparkfun Breakout Board (www.sparkfun.com/products/11403)
  • ATmega328P on Arduino

More information:

  • SD card is powered from 3.3V supply pin on Arduino.
  • 0-5V MOSI/SS/SCK signals are lowered to 0-3.3V by means of a resistive divider (560Ω over 1.1kΩ, I believe).
  • Some sources recommended a large pull-up resistor (~50kΩ) on MISO. This didn't seem to do anything except add a 3.3V DC offset to MISO. Strangely enough, removing the resistor did not remove the DC offset.
\$\endgroup\$
1
\$\begingroup\$

Are you sure your grounds are all connected? The scope trace looks like something is floating.

You are doing it wrong with the resistive divider. Dividers are affected by the load, and that's probably what is happening here.

Unfortunately the MCU on the Arduino doesn't support open drain outputs in SPI mode. You could implement bit-banging SPI with an open-drain output and then simply pull the MOSI and SCLK lines up to 3.3V. Alternatively use a dedicated level shifting IC or if it's just a hobby project a series resistor will probably be okay. Actually you could use a Zener diode too.

In short, your potential divider is most likely the problem.

\$\endgroup\$
  • \$\begingroup\$ But in my second graphic, the SCK waveform varies all the way from 0-3.3V. This would seem to indicate that my resistive divider is not being loaded by the SD card at all. \$\endgroup\$ – Ryan Jun 6 '14 at 15:43
  • \$\begingroup\$ The clock is generated by the micro, which is grounded. The response is generated by the card, which is not. You are probably grounding the card through the data lines. \$\endgroup\$ – user Jun 7 '14 at 10:02
  • \$\begingroup\$ The grounding issue might be worth looking at. But the blaming of the resistive divider is mistaken and misleading, especially when it is made with such low value resistances as used here. The problem is not with the MCU driven signals which you speak of, but rather with the single card-driven one. \$\endgroup\$ – Chris Stratton Oct 7 '14 at 16:27
0
\$\begingroup\$

enter image description here

I got this schematic with SDcard reader bought via ebay. Please not different resistor divider for various MCU outputs (SDcard reader inputs). My preference is to use some "level shifter" like 74HC4050 which supply (Vdd) pin has to be connected to +3.3V (not +5V!).

\$\endgroup\$
  • 2
    \$\begingroup\$ This does not answer the question. \$\endgroup\$ – Chris Stratton Oct 7 '14 at 16:29

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.