Micro-SD Card not formatted

Hi there!

I'm trying to realize the communiction with a Micro-SD Card using a self-Made shield. And of course it doesn't work :-)

The levelshifter shifts the hell out of my signals and the ones coming back from the card(watched it all with my oscilloscope). Using the CardInfo example of the SD library I even can initialize the Card properly. But there can't be found any partition on the card and I really can't tell why. I'm using a SanDisk 2GB and the Mega-Board.

Thing I already tried:

  • make it smaller than 1GB by partitioning
  • format it in almost all ways there are with "partition wizard" and "SDFormatter"
  • scream at it very roughly while looking at it very mean

The "Files" example of the same library cannot initialize the sd card don't know why...

Please help me, I'm right before jumping out of the window!!!!

Most likely it is not a format problem. The only sure way to format an SD card to the SD standard is to use SDformatter https://www.sdcard.org/downloads/formatter_3/.

Other utilities do not comply with the standard and won't help solve your problem.

Most likely you have a low level I/O problems.

It would be helpful if you ran two example from the SdFat library. SdFat is located here http://code.google.com/p/sdfatlib/downloads/list.

Run the SdInfo and QuickStart examples and post the error messages with error codes.

If you get a message like this with an errorCode, you have a basic SPI I/O problem.

From SdInfo:

card.init failed SD errorCode: 0X1 SD errorData: 0XFF

From QuickStart:

SD initialization failed. Do not reformat the card! Is the card correctly inserted? Is chipSelect set to the correct value? Is there a wiring/soldering problem? errorCode: 0x1, errorData: 0xff

Hi thanks for your quick response.

I formatted the card again with the SDFormatter 3.1 just in case and ran the SDInfo from SDFat lib:

type any character to start

init time: 1241 ms

Card type: SD1
readCID failed
SD errorCode: 0X10
SD errorData: 0X1F

this was on quarter speed.

The Quickstart told me this:

Card successfully initialized.

Can’t determine the card size.
Try another SD card or reduce the SPI bus speed.
The current SPI speed is: 4.00 MHz
Edit spiSpeed in this sketch to change it.

I tried to reduce SPI speed to SIXTEENTH speed, no difference

Card successfully initialized.

Can’t determine the card size.
Try another SD card or reduce the SPI bus speed.
The current SPI speed is: 0.50 MHz
Edit spiSpeed in this sketch to change it.

What can I do? Is the Miso compromised? I think the right signals reach the card, but the answer doesn’t find it’s way to the arduino.

I can post some osci-screenshots if you guys think it might help.

Maybe important: I have to try several times until it works. I blame it on my bad wiring. I messed up with my first layout so I had to cut traces and resolder them.

… typical issues when running an sdcard:

  1. miso vs. mosi
  2. missing decoupling capacitor close to the sdcard (min 10uF ceramic, between vcc and gnd)
  3. missing SDcard’s signals pull-up resistors - I always use ~10kohm on DO, DI, CS
  4. long wires (shall be <15cm)
    p.

Thanks Pito these are a few things I didn't had in mind!!!

  1. I'm pretty shure I didn't mix up MiSo and MoSi except the SD-Card wants to be the Master. But my Arduino gives the clock, so I don't think so :-)
  2. I'll definitly try this one!!
  3. You're right. I don't have these. I'm new to this so just confirming: About 10k in series on the 3.3V side of my levelshifter(so between shifter an SD-card). SDO probably means SD-Out, so the MiSo and SDI is SD-IN, so the MoSi? CS is the ChipSelect, Ok. SCK doesn't need no pullup, seems about right.
  4. Well I think i should cut my testboard wires a little :-)

First thing in the morning I'll try. If this works, you safed my bachelor thesis!

Thanks!!!

..pullup resistor - it means the resistor connected between the SDcard signal and VCC=3.3Volt (one side of the pullup resistor connected to the SDcard signal, the other side to 3.3Volt). p.

Sorry for beeing so needy, but this is what you were thinking right?

Is there any reason I shouldn't use that 22uF cap instead of a 10uF? I got several of these left...

Yes, it seems to be ok. Capacitor - of course you may use any capacitor 22uF - 47uF - 100uF, mind the aluminium and cheap tantalum capacitors have quite high ESR so their filtering effect for fast transients is small. The best results are with smd ceramic multilayer capacitors ie. 10u, 22u, etc. the bigger value the better :) . I am using 2 x 10uF ceramic 0805 smd in parallel with my sdcard adapter (must be soldered very close to the sdcard pins). p.

It's definitely an SPI problem. It appears to nearly work. This may because SdFat does retries during initialization.

Arduino does not support hardware CRC but SdFat has software CRC which is normally disabled.

Could you please edit SdFatConfig.h at about line 35 and enable CRC like this:

#define USE_SD_CRC 2

Then run SdInfo again. This may give a better indication of where the problem is.

It would be great if there was a way to connect MISO directly without the level shifter. Most SD shields connect MISO directly. This works even though a high level of 3.3V seem marginal as an input to the ATmega.

The spec says the Min high input is 0.6Vcc. Guess it works since the Max low input is 0.3Vcc.

Edit:

I checked some posting on AVR Freaks and the claim is:

The AVR clearly has much better specification, as at 5V vilmax is 0.42*Vcc=2.1V and vihmin is 0.52*Vcc=2.6V.

I guess this is why commercial shields work well.

Hi fat16lib,

I edited the header

#ifndef SdFatConfig_h
#define SdFatConfig_h
#include <stdint.h>
#define USE_SD_CRC 2

ran the SD-Info again and there was no difference. Same error code and so on…
I’ll try to connect the Miso directly to the Arduino and post the results.

The SD status, errorData, has too many one bits to make sense.

For read CID the status 0X1F, would be:

• In idle state: The card is in idle state and running the initializing process. • Erase reset: An erase sequence was cleared before executing because an out of erase sequence command was received. • Illegal command: An illegal command code was detected. • Communication CRC error: The CRC check of the last command failed. • Erase sequence error: An error in the sequence of erase commands occurred

This just can't be. That's why I suspect MISO.

Ok, just tried to connect Miso directly to the board. Looks very adventurous and the signal is not very clean, BUT

init time: 1387 ms

Card type: SD2

Manufacturer ID: 0X1B OEM ID: SM Product: 00000 Version: 1.0 Serial number: 3990855694 Manufacturing date: 9/2011

readCSD failed SD errorCode: 0X10 SD errorData: 0XFF

That was the answer. Maybe there's a loose contact or something and I couldn't get the rest of the message...

Yeah, tried it again:

init time: 3 ms

Card type: SD2

Manufacturer ID: 0X1B OEM ID: SM Product: 00000 Version: 1.0 Serial number: 3990855694 Manufacturing date: 9/2011

cardSize: 3911680 (512 byte blocks) flashEraseSize: 64 blocks eraseSingleBlock: true

SD Partition Table part,boot,type,start,length 1,0X0,0X6,129,3911551 2,0X0,0X0,0,0 3,0X0,0X0,0,0 4,0X0,0X0,0,0

Volume is FAT16 blocksPerCluster: 64 clusterCount: 61110 freeClusters: 61110 fatStartBlock: 130 fatCount: 2 blocksPerFat: 239 rootDirStart: 608 dataStartBlock: 640

I think I should put these pullup-resistors and the cap in anyways, or what do you think? Never change a running system?

Thank you so much!!!!!

pito's advice is better than mine on caps since he is running SD cards on very fast systems.

I really like a pullup between 3.3V and MISO on the card. This holds MISO high when there is no card and insures there won't be a false acceptance of CMD0, the first initialization command. This can happen due to noise on MISO since I do thousands of retries waiting for the card to go ready. Success for this command is a status of 0X01 which can easily happen with noise and no CRC.

0XFF is busy so if MISO is held high, commands fails with a busy timeout.

Good point. I'll definitly put it in my layout, I still can solder a 0 Ohm resisistor when I have to decide it's a bad idea anyhow! Thanks again guys. I was dealing with this problem for 3 days straight.

If you guys are ever near to Munich, give me a call :-)

Thread closed.