cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO SD DMA transfer hangs waiting for SD transfer complete

Rhodes.Keith
Associate II
Posted on March 27, 2015 at 22:03

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

#sdio #stm32 #fatfs
1 REPLY 1
Walid FTITI_O
Senior II
Posted on June 07, 2016 at 13:42

Hi rhodes.keith,

I suggest that you take a look to this [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32Cube%20%2B%20F4-Discovery%20%2B%20FatFS&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=107]thread

-Hannibal-