SD Card Timeout on read - STM32F207VCT6

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
dismirlian
Posts: 65
Joined: Fri Dec 20, 2013 3:59 pm
Has thanked: 1 time
Been thanked: 16 times

SD Card Timeout on read - STM32F207VCT6

Post 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;
}
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: SD Card Timeout on read - STM32F207VCT6

Post by Giovanni »

Hi,

Could you try another brand/type of card?

Giovanni
dismirlian
Posts: 65
Joined: Fri Dec 20, 2013 3:59 pm
Has thanked: 1 time
Been thanked: 16 times

Re: SD Card Timeout on read - STM32F207VCT6

Post 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.
dismirlian
Posts: 65
Joined: Fri Dec 20, 2013 3:59 pm
Has thanked: 1 time
Been thanked: 16 times

Re: SD Card Timeout on read - STM32F207VCT6

Post 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.
Post Reply