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!!!!
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
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.
Thanks Pito these are a few things I didn't had in mind!!!
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
I'll definitly try this one!!
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.
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!
..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.
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.42Vcc=2.1V and vihmin is 0.52Vcc=2.6V.
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
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