We've recently been struggling with a hardware issue concerning activating the SD card reliably on the Uno.
We have it set to all of the stock pins, with the exception of chip select, which is on Pin 10 instead of Pin 4. We've had it working several times and successfully written data, however, now, no matter the configuration we put the card in, and even using the stock SD card test moving back to pin 4, we cannot get the card to function reliably with the Uno. However, it functions normally with an SD card slot on a PC.
I've attached the two most common pin setups we used, a basic generic direct mapping from pin to pin with a 3.3v Supply off the board to V_DD, or our voltage divided supply so that all pins are operating on 3.3V.
You shouldn't have a voltage divider on the MISO line. That's an output from the SD card and is already 3.3V.
Starting at the clipped corner the pins should be:
9 No Connection
1 CS <- SS with voltage divider
2 Data In <- MOSI with voltage divider
3 Ground <-> Ground
4 Vss <- +3.3v
5 CLK <- SCK with voltage divider
6 Vss2 <-> Ground
7 Data Out -> MISO (NO voltage divider)
8 No Connection
Alright, I'm sure we haven't had it like that, I just hastily did the diagram from memory. We also just tried your suggestion and it's still not firing up. We've tried multiple spots on the breadboard as well as 1 to 1 solder on an old SD card. It's been frustrating to say the least.
Are SD card failures most commonly related to hardware/compatibility issues or software?
We're also running an LCD screen if that helps as well.
As of right now, we have the screen disabled while running the SD card because we're attempting to troubleshoot it, however, we will eventually have to run them off the SPI at the same time. However, when we had it first working and datalogging, I had both the LCD and the SD card active.
JohnDoeSmith:
Dont think we'll be able to get ahold of IC level shifters. I guess the best bet is to go with an older card?
The best bet would be to run your AVR at 3.3v using a 3.3v voltage regulator. Running the avr at 16mhz at 3.3v is only slightly overclocking it by about 2 mhz, but these chips are rock solid and i have never come across any instability. If you run the AVR at 3.3v, then you avoid all this hassle of level shifting etc and can directly interface to the SD card
We're running the whole project off the Uno Board, so I dont know if that's an option or not. Went to all the electronics stores and we found out we can't get any level shifters there. Voltage regulators probably wont fit on the board either, so we're either having to buy an ethernet shield or we're SOL for having the SD card working
JohnDoeSmith:
We're running the whole project off the Uno Board, so I dont know if that's an option or not. Went to all the electronics stores and we found out we can't get any level shifters there. Voltage regulators probably wont fit on the board either, so we're either having to buy an ethernet shield or we're SOL for having the SD card working
You can try resistor based shifting, just use the values i have used and keep the wires short. The spi bus switches at MHZ speeds so kep the wires short as otherwise they can lead to isntability. Also please try to keep a supply decoupling capacitor close to the SD cards power input.