SD card issues

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello.

I run the FatFS example program and I have initialized the SD card interface on a SAMD20 with these parameters:

#define SD_MMC_SPI                 SERCOM1

#  define SD_MMC_SPI_PINMUX_SETTING SPI_SIGNAL_MUX_SETTING_D

#  define SD_MMC_SPI_PINMUX_PAD0 PIN_PA16C_SERCOM1_PAD0 //MOSI

#  define SD_MMC_SPI_PINMUX_PAD1 PIN_PA17C_SERCOM1_PAD1 //SCK

#  define SD_MMC_SPI_PINMUX_PAD2 PINMUX_UNUSED

#  define SD_MMC_SPI_PINMUX_PAD3 PIN_PA19C_SERCOM1_PAD3 //MISO

#define SD_MMC_CS                  PIN_PA22

 

When the application is running it is giving me constantly the following error:

Start SD card install

sd_cmd8: CMD8 resp32 0x00000000 UNUSABLE CARD

SD/MMC card initialization failed

 

Does anyone know what kind of error is that?

This topic has a solution.
Last Edited: Wed. Mar 7, 2018 - 08:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PINMUX defines look like this PINMUX_PA16C_SERCOM1_PAD0, your PIN_ defines will not include the mux setting (should be easy enough to spot such a problem just looking at the PORT config when debugging).

/Lars

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Argh!!! Sorry for my ignorance but I am really quite beginner with ARMs and generally speaking microprocessors. Perhaps I need to read some extra books. I am not quite sure of what is the PINMUX defines although I will take it as you stated it (and it seems it proceeds somehow). Using the following (with PINMUX) defines:

#define SD_MMC_SPI                 SERCOM1

#define SD_MMC_SPI_PINMUX_SETTING SPI_SIGNAL_MUX_SETTING_D
#define SD_MMC_SPI_PINMUX_PAD0 PINMUX_PA16C_SERCOM1_PAD0 //MOSI
#define SD_MMC_SPI_PINMUX_PAD1 PINMUX_PA17C_SERCOM1_PAD1 //SCK
#define SD_MMC_SPI_PINMUX_PAD2 PINMUX_UNUSED
#define SD_MMC_SPI_PINMUX_PAD3 PINMUX_PA19C_SERCOM1_PAD3 //MISO

#define SD_MMC_CS                  PIN_PA22

It halts on sd_mmc_spi_start_read_block() function after the call to spi_read_buffer_wait(...). It seems that some kind of token is in error as it runs the following:

sd_mmc_spi_debug("%s: Out of range data error token\n\r", __func__);

sd_mmc_spi_err = SD_MMC_SPI_ERR_OUT_OF_RANGE;

What does the 'Data access out of range' means?

#define SD_MMC_SPI_ERR_OUT_OF_RANGE      11 //! Data access out of range

The Physical Layer Simplified Specification for the SD cards state the following:

Any idea on what exactly is this and how it can be solved?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The command argument was out of the allowed range for this card.

I don't know enough about SD communication to know if that could be the result of bad communication but anyway, how is the card connected to the SAMD20? Does it help to lower the SPI clock speed? Did you try another card?

/Lars 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I tried to even lower the SPI clock speed to 100kHz with no luck. The SD I had was a SanDisk Ultra 16GB class 10 SDHC. I just bought a new SDHC card 8GB class 10 from Intenso and still the same problem.

The problem appears when the software is trying to send the CMD9 command. From the specs, that command is the SEND_CSD to obtain the Card Specific Data (CSD register) like block length, card storage capacity, etc. All the rest communication (previous commands) seem to operate good until that command that gives the error.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Victory!!!

I connected an Adafruit Feather Datalogger board (it has SD slot) on the microprocessor and it worked great!

I immediately started looking on my custom made SD circuit with the multi-meter and I discovered that the GND pin on the SD had not any ground contact and as such I had to rework it. Now it works fine.

Lajon, thank you very much for the suggestion about the PINMUX_ defines. Without it I would probably still be searching for the problem.

Although I will mark the post as answered later on, I have a quick question. On the Adafruit board it has a pull-up resistor of 100kOhm for the ChipSelect pin of the SD card. I don't have any such pull-up on my board and it works. Isn't the SAMD microprocessor pin has the Internal pull-up flag enabled? I shouldn't be worry that my board operates without a pull-up resistor, right?

Efthymios

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right, internal pullup works ok for the CD.

/Lars