AnsweredAssumed Answered

SDIO SD DMA transfer hangs waiting for SD transfer complete

Question asked by rhodes.keith on Mar 27, 2015
Latest reply on Jun 7, 2016 by FTITI.Walid
I have an STM32F427 using the 1.4 version of the STMCube software with the HAL drivers.

I am using the stock 1.4 and calling HAL_SD_ReadBlocks_DMA to transfer 1 block from the SD card. Periodically, it hangs in the following function waiting for the SD transfer to complete:

static void SD_DMA_RxCplt(DMA_HandleTypeDef *hdma)
{
  SD_HandleTypeDef *hsd = (SD_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent;
  
  /* DMA transfer is complete */
  hsd->DmaTransferCplt = 1;
  
  /* Wait until SD transfer is complete */
  while(hsd->SdTransferCplt == 0) <----- hangs forever
  {
  }

...

It happens one time out of maybe 1000 times when transferring one block. When transferring more than one block in the ReadBlocks_DMA... call, it hangs one time out of 50.

It looks like the DMA and SD command are setup correctly, but the SD complete status is never set in the HAL_SD_IRQHandler. When it hangs like this, it appears that the SD IRQ Handler is never called with the SDIO_IT_DATAEND flag.

I am using DMA for ethernet as well, but that is on a different DMA channel.

I have the SD and DMA interrupt priorities set the same as the v1.4 code.

Any thoughts?

Thanks...Keith


Outcomes