cancel
Showing results for 
Search instead for 
Did you mean: 

SDMMC Data Timeout Error

Looke Jean
Associate II
Posted on April 30, 2018 at 18:19

Hi

I'm trying to write some test data to SD card by DMA with Nucleo-F767Zi.

Every 100ms I write 20 blocks to SD card by calling the HAL_SD_WriteBlocks_DMA() method.

I have a counter to record how many times the HAL_SD_WriteBlocks_DMA() have been called since the power up.

The HAL_SD_ERROR_DATA_TIMEOUT error interrupt rise up after hundreds calls , sometime several calls.

I read the reference manual.

It says 'When transmitting data, the timeout occurs if the DPSM stays in the Busy state for longer than the programmed timeout period'.

I wonder what should I do to prevent the HAL_SD_ERROR_DATA_TIMEOUT error?

------------------------------------------------------------

The clock of SDMMC is 24Mhz. The SD card is Sony 16GB class 4.

SDMMC configuration is:

SDHandle_SDMMC.Instance = SDMMC2;

SDHandle_SDMMC.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;

SDHandle_SDMMC.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;

SDHandle_SDMMC.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;

SDHandle_SDMMC.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE;

SDHandle_SDMMC.Init.ClockDiv = 0;

The related interrupt code in HAL_SD_IRQHandler is:

……

else if(__HAL_SD_GET_FLAG(hsd, SDMMC_IT_DCRCFAIL | SDMMC_IT_DTIMEOUT | SDMMC_IT_RXOVERR | SDMMC_IT_TXUNDERR) != RESET)

{

/* Set Error code */

if(__HAL_SD_GET_FLAG(hsd, SDMMC_IT_DCRCFAIL) != RESET)

{

hsd->ErrorCode |= HAL_SD_ERROR_DATA_CRC_FAIL;

}

if(__HAL_SD_GET_FLAG(hsd, SDMMC_IT_DTIMEOUT) != RESET)

{

hsd->ErrorCode |= HAL_SD_ERROR_DATA_TIMEOUT;

}

if(__HAL_SD_GET_FLAG(hsd, SDMMC_IT_RXOVERR) != RESET)

{

hsd->ErrorCode |= HAL_SD_ERROR_RX_OVERRUN;

}

if(__HAL_SD_GET_FLAG(hsd, SDMMC_IT_TXUNDERR) != RESET)

{

hsd->ErrorCode |= HAL_SD_ERROR_TX_UNDERRUN;

}

……
1 REPLY 1

Can't help you, bumping you off my feed

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