Electronic – Interfacing 3.3V SD card MISO output to ATmega328P

interfacesdspi

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.

Best Answer

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.