Another SD card problem :( But this one is more challenging

Hi,

I know that there are a few dozens other topics that go over this problem however, I read most of them and still couldn't fix my problem with my SD card and card module. The problem that I encountered is that it give's so much different errors that I don't know what to do anymore.

First I tried the "sdcardinfo" from examples and that gave me this error:

Initializing SD card... Wiring is correct and a card is present.

Card type: SD2
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card

I tried to format the SD card to fat16 but that didn't work. I even downloaded something called SDformatter to try fat16 and fat32, but still i wouldn't work.

Then I read the article below, that said that I needed to try the "files" sketch from examples. Did that... but then this was the error:

Article: https://forum.arduino.cc/index.php?topic=296324.0

Initializing SD card...initialization failed!

The next shot I tried was to download "sdfat" of Github and running the "quickstart" sketch. aaaand as you may have guessed it gave an error, that was this.

Enter the chip select pin number: 53

Assuming the SD is the only SPI device.
Edit DISABLE_CHIP_SELECT to disable another device.

SD initialization failed.
Do not reformat the card!
Is the card correctly inserted?
Is chipSelect set to the correct value?
Does another SPI device need to be disabled?
Is there a wiring/soldering problem?

errorCode: 0x18, errorData: 0x99

Restarting

So that wasn't a success ether. Then I tried the "sdinfo" sketch from the sdftat library and this was the error for that one.

init time: 2 ms
readInfo failed
SD errorCode: SD_CARD_ERROR_READ_TOKEN = 0x18
SD errorData = 0x80

type any character to start

And again a different error. Lastly I tried the "sderrorcode" skecht from the sdfat library and this was the error for that one.

Code,Symbol - failed operation
0X00,SD_CARD_ERROR_NONE - No error
0X01,SD_CARD_ERROR_CMD0 - Card reset failed
0X02,SD_CARD_ERROR_CMD2 - SDIO read CID
0X03,SD_CARD_ERROR_CMD3 - SDIO publish RCA
0X04,SD_CARD_ERROR_CMD6 - Switch card function
0X05,SD_CARD_ERROR_CMD7 - SDIO card select
0X06,SD_CARD_ERROR_CMD8 - Send and check interface settings
0X07,SD_CARD_ERROR_CMD9 - Read CSD data
0X08,SD_CARD_ERROR_CMD10 - Read CID data
0X09,SD_CARD_ERROR_CMD12 - Stop multiple block read
0X0A,SD_CARD_ERROR_CMD13 - Read card status
0X0B,SD_CARD_ERROR_CMD17 - Read single block
0X0C,SD_CARD_ERROR_CMD18 - Read multiple blocks
0X0D,SD_CARD_ERROR_CMD24 - Write single block
0X0E,SD_CARD_ERROR_CMD25 - Write multiple blocks
0X0F,SD_CARD_ERROR_CMD32 - Set first erase block
0X10,SD_CARD_ERROR_CMD33 - Set last erase block
0X11,SD_CARD_ERROR_CMD38 - Erase selected blocks
0X12,SD_CARD_ERROR_CMD58 - Read OCR register
0X13,SD_CARD_ERROR_CMD59 - Set CRC mode
0X14,SD_CARD_ERROR_ACMD6 - Set SDIO bus width
0X15,SD_CARD_ERROR_ACMD13 - Read extended status
0X16,SD_CARD_ERROR_ACMD23 - Set pre-erased count
0X17,SD_CARD_ERROR_ACMD41 - Activate card initialization
0X18,SD_CARD_ERROR_READ_TOKEN - Bad read data token
0X19,SD_CARD_ERROR_READ_CRC - Read CRC error
0X1A,SD_CARD_ERROR_READ_FIFO - SDIO fifo read timeout
0X1B,SD_CARD_ERROR_READ_REG - Read CID or CSD failed.
0X1C,SD_CARD_ERROR_READ_START - Bad readStart argument
0X1D,SD_CARD_ERROR_READ_TIMEOUT - Read data timeout
0X1E,SD_CARD_ERROR_STOP_TRAN - Multiple block stop failed
0X1F,SD_CARD_ERROR_WRITE_DATA - Write data not accepted
0X20,SD_CARD_ERROR_WRITE_FIFO - SDIO fifo write timeout
0X21,SD_CARD_ERROR_WRITE_START - Bad writeStart argument
0X22,SD_CARD_ERROR_WRITE_PROGRAMMING - Flash programming
0X23,SD_CARD_ERROR_WRITE_TIMEOUT - Write timeout
0X24,SD_CARD_ERROR_DMA - DMA transfer failed
0X25,SD_CARD_ERROR_ERASE - Card did not accept erase commands
0X26,SD_CARD_ERROR_ERASE_SINGLE_SECTOR - Card does not support erase
0X27,SD_CARD_ERROR_ERASE_TIMEOUT - Erase command timeout
0X28,SD_CARD_ERROR_INIT_NOT_CALLED - Card has not been initialized
0X29,SD_CARD_ERROR_INVALID_CARD_CONFIG - Invalid card config
0X2A,SD_CARD_ERROR_FUNCTION_NOT_SUPPORTED - Unsupported SDIO command
0X2B,SD_CARD_ERROR_UNKNOWN - Unknown error

I don't think anyone will get this, but if you do please let me know.

Have a nice laugh at my error :sweat_smile:

Any other SPI device interfering with the SD? or poor SPI signals quality? Did you try with multiple Sd cards ? How are you powering up the SD card hardware?

What Arduino board are you using? Please post a clear photo of your actual hardware connections.

I don't have anything else connected to the arduino so i assume there is no other spi device. For the strength of the signal: I don't really know, and don't know how to test this ether :relaxed: the boards that I'm using are the UNO R3 (CH340G) MEGA328P as listed and the MEGA 2560 R3 ATmega2560 R3 AVR. tried them both but nether did work.

The circuit is as shown on the picture (hope you can see it but I checked 50 times if the wiring was correct)

From my experience its likely the SD clock speed. Try SD.begin with SPI clock speed definition. With my current setup the SD_SCK_MHZ can be as high as 35 MHZ but getting it to be reliable is typically 25 MHZ or less. Try 15 MHZ, if it works then go up in speed until it throws error again then back off.

    // SD CARD SETUP ====================================================================
  // see if the card is present and can be initialized:  (Use highest SD clock possible, but lower if has error, 35 Mhz works)
  if (!sd.begin(sdChipSelect, SD_SCK_MHZ(15))) {
    Serial.println("Card init. failed!");
    while (1) yield(); 
  }
1 Like

smailen: From my experience its likely the SD clock speed. Try SD.begin with SPI clock speed definition. With my current setup the SD_SCK_MHZ can be as high as 35 MHZ but getting it to be reliable is typically 25 MHZ or less. Try 15 MHZ, if it works then go up in speed until it throws error again then back off.

Ah that is a thing I could try. But how exactly did you change the clock speed because when I try the "SD_SCK_MHZ(15)))" it says that it was not declared in this scope. Do I need to define something or is that another library?

It does give me this error code tho:

exit status 1
'SD_SCK_MHZ' was not declared in this scope
note: suggested alternative: 'SPI_SCK_PIN'

Hey, sorry didn’t get notified you had responded to this. You are including the correct libraries right? These:

#include <SPI.h>
#include “SdFat.h”