Page 1 of 1

SD Card Timeout on read - STM32F207VCT6

Posted: Mon Feb 10, 2014 3:03 pm
by dismirlian
Hello, I am trying to read a SD card using the MMC over SPI driver.

I am having a sporadic timeout in the function mmcSequentialRead, which I copy below for convenience. The MCU doesn't receive the 0xFE. I tried waiting in an infinite loop, but the 0xFE never arrives. The problem is not very frequent (for example, it appears when I try to read files larger than 100kB).

Has someone seen a similar problem? What could be the cause?

Thank you very much for your help.

Diego.

Code: Select all

bool_t mmcSequentialRead(MMCDriver *mmcp, uint8_t *buffer) {
  int i;

  chDbgCheck((mmcp != NULL) && (buffer != NULL), "mmcSequentialRead");

  if (mmcp->state != BLK_READING)
    return CH_FAILED;

  for (i = 0; i < MMC_WAIT_DATA; i++) {
    spiReceive(mmcp->config->spip, 1, buffer);
    if (buffer[0] == 0xFE) {
      spiReceive(mmcp->config->spip, MMCSD_BLOCK_SIZE, buffer);
      /* CRC ignored. */
      spiIgnore(mmcp->config->spip, 2);
      return CH_SUCCESS;
    }
  }
  /* Timeout.*/
  spiUnselect(mmcp->config->spip);
  spiStop(mmcp->config->spip);
  mmcp->state = BLK_READY;
  return CH_FAILED;
}

Re: SD Card Timeout on read - STM32F207VCT6

Posted: Mon Feb 10, 2014 3:40 pm
by Giovanni
Hi,

Could you try another brand/type of card?

Giovanni

Re: SD Card Timeout on read - STM32F207VCT6

Posted: Tue Feb 11, 2014 2:01 pm
by dismirlian
Thank you for the suggestion Giovanni. I've done some further testing, and I also get some read errors, so I believe I have an electrical problem; I'll keep you posted...

Thanks!
Diego.

Re: SD Card Timeout on read - STM32F207VCT6

Posted: Thu Feb 13, 2014 2:14 pm
by dismirlian
I've finally had time to look at this problem, and found that the culprit was a wrong TVS soldered to the SPI lines (too much capacitance).

Thanks for your support Giovanni.

Diego.