2012-09-11 11:57 PM
Hi!
I've got another problem with my STM32F205. The Data Timeout timer doesn't start and when there is no answer from SD Card, the system waits in loop for watchdog reset ;). Here is a function. The code is working properly but sometimes (after re-init of the card) it hangs up.SD_Error SD_SendSDStatus(uint32_t *psdstatus)
{ SD_Error errorstatus = SD_OK; uint32_t count = 0; if (SDIO_GetResponse(SDIO_RESP1) & SD_CARD_LOCKED) { errorstatus = SD_LOCK_UNLOCK_FAILED; return(errorstatus); } /*!< Set block size for card if it is not equal to current block size for card. */ SDIO_CmdInitStructure.SDIO_Argument = 64; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SET_BLOCKLEN; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SD_CMD_SET_BLOCKLEN); if (errorstatus != SD_OK) { return(errorstatus); } /*!< CMD55 */ SDIO_CmdInitStructure.SDIO_Argument = (uint32_t) RCA << 16; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SD_CMD_APP_CMD); if (errorstatus != SD_OK) { return(errorstatus); } SDIO_DataInitStructure.SDIO_DataTimeOut = 0x10000; SDIO_DataInitStructure.SDIO_DataLength = 64; SDIO_DataInitStructure.SDIO_DataBlockSize = SDIO_DataBlockSize_64b; SDIO_DataInitStructure.SDIO_TransferDir = SDIO_TransferDir_ToSDIO; SDIO_DataInitStructure.SDIO_TransferMode = SDIO_TransferMode_Block; SDIO_DataInitStructure.SDIO_DPSM = SDIO_DPSM_Enable; SDIO_DataConfig(&SDIO_DataInitStructure); /*!< Send ACMD13 SD_APP_STAUS with argument as card's RCA.*/ SDIO_CmdInitStructure.SDIO_Argument = 0; SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SD_APP_STAUS; SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short; SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No; SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable; SDIO_SendCommand(&SDIO_CmdInitStructure); errorstatus = CmdResp1Error(SD_CMD_SD_APP_STAUS); if (errorstatus != SD_OK) { return(errorstatus); }while (!(SDIO->STA &(SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR)))
{ if (SDIO_GetFlagStatus(SDIO_FLAG_RXFIFOHF) != RESET) { for (count = 0; count < 8; count++) { *(psdstatus + count) = SDIO_ReadData(); } psdstatus += 8; } }Thered while
sometimes never ends. Why the DataTimeout do not occur? Why it not even starts? When I stop my program and watch the SDIO->DTIMER value it's still on the start value. I wan't to rewrite the library by own, because it's not ''FreeRTOS ready'', but I must understand how it works and why it's not working as I think. Thanks for Your helpBest regardsKonoppo #sdio #timeout2014-02-17 03:02 AM
Hello,
Did you find solution for this? It happens frequently in my project.