Skip to main content
petr
Associate
June 19, 2015
Question

STM32 SDHC in sleep mode ? [SOLVED]

  • June 19, 2015
  • 3 replies
  • 1002 views
Posted on June 20, 2015 at 00:28

Hello,

i have a little problem with SDHC card via SDIO. I use 3 types of sd cards, all works but with one type i have problem. When i mount sd and immediately  start write or read, all is ok, but when add some pause between reading or writing (cca > 50ms) i get from Fatfs DISK IO Error.  Problem is in function HAL_SD_ReadBlocks:

  /* Set Block Size for Card */

  sdio_cmdinitstructure.Argument         = (uint32_t) BlockSize;

  sdio_cmdinitstructure.CmdIndex         = SD_CMD_SET_BLOCKLEN;

  sdio_cmdinitstructure.Response         = SDIO_RESPONSE_SHORT;

  sdio_cmdinitstructure.WaitForInterrupt = SDIO_WAIT_NO;

  sdio_cmdinitstructure.CPSM             = SDIO_CPSM_ENABLE;

  SDIO_SendCommand(hsd->Instance, &sdio_cmdinitstructure);

 

  /* Check for error conditions */

  errorstate = SD_CmdResp1Error(hsd, SD_CMD_SET_BLOCKLEN);

 

  if (errorstate != SD_OK)

  {

    return errorstate; //Here i get Timeout

  }

Others Card works fine (different company)

PS: i use HAL library with DMA transfer created in STM32CubeMx.

Thank You

#sd-card #sdio-sdhc-stm32
This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
June 19, 2015
Posted on June 20, 2015 at 01:35

Card may have a low power mode, check SD/MMC specs to see if  there is a magic sequence to awaken. Check the parameter blocks returned by the card, size, features, etc.

Does the command succeed if retried? or are you dead in the water?

The stack implements no error recovery or retry strategy, if this is a commercial system consider robustness issues. The code examples are provided as is, for demonstrational purposes.

Not a HAL/Cube user.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
petr
petrAuthor
Associate
June 20, 2015
Posted on June 20, 2015 at 12:54

Problem solved. It was error between chair and keyboard. If you have same problem, change GPIO settings for SDIO to GPIO_InitStruct.Pull = GPIO_PULLUP.

Thank you
Tesla DeLorean
Guru
June 20, 2015
Posted on June 20, 2015 at 15:52

A lot of designs have external pull-ups.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..