Skip to main content
Associate II
August 6, 2026
Question

SDIO Gets stuck

  • August 6, 2026
  • 2 replies
  • 51 views

hi 

I am trying to get an sd card to work with my custom board, uses STM32F412RET6.

when i try to mount or do anything other than init in 1 bit mode the code gets stuck at this point. I have been able to read block size and number from the SD card but that is it.

 while(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT))
{
if(__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXDAVL))
{
*(tempscr + index) = SDIO_ReadFIFO(hsd->Instance);
index++;
}
else if(!__HAL_SD_GET_FLAG(hsd, SDIO_FLAG_RXACT))
{
break;
}

if((HAL_GetTick() - tickstart) >= SDMMC_SWDATATIMEOUT)
{
return HAL_SD_ERROR_TIMEOUT;
}
}

 

2 replies

TDK
August 6, 2026

The SDIO peripheral has race conditions where data needs read out quickly enough otherwise it overflows. Use a higher clock prescaler to see if that solves the problem. If it does, the solution would be to use DMA or rewrite code to be faster. Using Release mode can be a bandaid.

"If you feel a post has answered your question, please click ""Accept as Solution""."
drJonesyAuthor
Associate II
August 6, 2026

DMA is enabled and prescaler is set to 250