cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 SDHC in sleep mode ? [SOLVED]

petr
Associate II
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
3 REPLIES 3
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 Venmo
Up vote any posts that you find helpful, it shows what's working..
petr
Associate II
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
Posted on June 20, 2015 at 15:52

A lot of designs have external pull-ups.

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