AnsweredAssumed Answered

Writing multiple blocks to SD card fails

Question asked by Ivan Ivan on Aug 2, 2017
Latest reply on Aug 3, 2017 by Ivan Ivan

Hello. I am developing application that involves writing multiple blocks (of 512 bytes) to SD card. It is a part of USB MSC application, multiblock operations are required for correct and fast functioning. A BSP_SD_WriteBlocks() recommended routine hangs when writing several blocks. Reading multiple blocks performs OK, writing single block also is fine, but multiple blocks write transmission fails. My code is simple:

BSP_SD_WriteBlocks((uint32_t *)buf, blk_addr, blk_len, 1000);

uint32_t state1 = PERSONAL_SD_GetCardState();

uint32_t error1 = PERSONAL_SD_GetCardError() ;
//HANGS HERE
while (BSP_SD_GetCardState() != SD_TRANSFER_OK)
{
}

I have added two subroutines to stm32746g_discovery_sd.h to understand what is happening with card:

uint32_t PERSONAL_SD_GetCardState(void) {
return ( (uint32_t)(HAL_SD_GetCardState(&uSdHandle) ) );
}
uint32_t PERSONAL_SD_GetCardError(void) {
return uSdHandle.ErrorCode;
}

During debug:

state1 gets assigned to 6 , which is "Card is receiving operation information". (I am expecting it to be 1, or card ready)

error1 gets assigned to 8 , which is "Data timeout" (I am expecting it to be SDMMC_ERROR_NONE, or 0)

 

How can I overcome this issue and make sd card correctly accept several blocks in one operation?

Outcomes