2018-04-27 10:33 AM
Hi,
I am using the STM32F407VG and try to read an SD Card over SDIO in 4 bit mode.
I have downloaded the fatfs driver from this site:
The initialization works absolutely fine until the second invocation of check_fs in line 3008 of ff.c 'fmt = bsect ? check_fs(fs, bsect) : 3; /* Check the partition */'(Note: The first invocation of check_fs in line 2998 'fmt = check_fs(fs, bsect);' returns the correct value (2))
Where it sticks after the check_fs invocation is in the interrupt of the DMA RX interrupt callback:
static void SD_DMA_RxCplt(DMA_HandleTypeDef *hdma)
{
SD_HandleTypeDef *hsd = (SD_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent;
/* DMA transfer is complete */
hsd->DmaTransferCplt = 1U;
/* Wait until SD transfer is complete */
while(hsd->SdTransferCplt == 0U)
{
}
/* Disable the DMA channel */
HAL_DMA_Abort(hdma);
/* Transfer complete user callback */
HAL_SD_DMA_RxCpltCallback(hsd->hdmarx);
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
line 9 ('while(hsd->SdTransferCplt == 0U)).
Any ideas what is going wrong?
2018-04-27 02:36 PM
The DISKIO or SDIO layer isn't working properly or returning inconsistent data.
Review current HAL examples.
2018-05-09 05:16 AM
Now I figured out, the second check_fs-call isn't working because theHAL_SD_IRQHandler-interrupt-function isn't setting the hsd->SdTransferCplt = 1U; due to a CRC error. So the SD_DMA_RxCplt-interrupt-functionends up in the infinite while loopwhile(hsd->SdTransferCplt == 0U).
So my questions changed to: Why I am getting a CRC-error in the second invocation of the check_fs-function (always in the second)?
The CRC-error check happens here:
void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd)
{
/* Check for SDIO interrupt flags */
if (__HAL_SD_SDIO_GET_FLAG(hsd, SDIO_IT_DATAEND))
{
__HAL_SD_SDIO_CLEAR_FLAG(hsd, SDIO_IT_DATAEND);
/* SD transfer is complete */
hsd->SdTransferCplt = 1U;
/* No transfer error */
hsd->SdTransferErr = SD_OK;
HAL_SD_XferCpltCallback(hsd);
}
--------> else if (__HAL_SD_SDIO_GET_FLAG(hsd, SDIO_IT_DCRCFAIL))
{
__HAL_SD_SDIO_CLEAR_FLAG(hsd, SDIO_FLAG_DCRCFAIL);
hsd->SdTransferErr = SD_DATA_CRC_FAIL;
HAL_SD_XferErrorCallback(hsd);
}
else if (__HAL_SD_SDIO_GET_FLAG(hsd, SDIO_IT_DTIMEOUT))
{�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
So the execution never reaches
hsd->SdTransferCplt = 1U; and is ending up in the endless while loop.
2018-05-18 08:29 AM
I attached a minimal project of my problem. May be someone can take a look over it.
________________ Attachments : sdio_test.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hxb1&d=%2Fa%2F0X0000000b08%2F8lobDjfF.aLy9ggNKwDEv.43.r5iLWiTdrl2mS8iWDM&asPdf=false