Skip to main content
JBond.1
Senior
November 3, 2023
Question

Stuck while reading/wirting from/to SD card

  • November 3, 2023
  • 1 reply
  • 880 views

Hi, I have STM32F407 and trying to read/wirte from/to SD card and often the code get stuck in the this loop:

 

static uint32_t SD_FindSCR(SD_HandleTypeDef *hsd, uint32_t *pSCR)
{
 //...

 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_DATATIMEOUT)
 {
 return HAL_SD_ERROR_TIMEOUT;
 }
 }

 //...
}

 

 for some reason SDMMC_DATATIMEOUT is huge number

 

#ifndef SDMMC_DATATIMEOUT
#define SDMMC_DATATIMEOUT 0xFFFFFFFFU
#endif /* SDMMC_DATATIMEOUT */

 

Where could I redefine it so I would not need to edit generated code?

Also why do I get stuck in this loop in the first place? (files are not huge to read/write so this should not be an issue?)

Could it be the issue after I upgraded CubeMX 6.6.1 to 6.9.2?

This topic has been closed for replies.

1 reply

JBond.1
JBond.1Author
Senior
November 3, 2023

It seems I had this error, because of bad power supply. Attached too many things to power supply and this started happening. It seems to be fixed!