cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO DMA hang

mmetzger
Associate II
Posted on February 29, 2016 at 08:08

Hello,

I'm trying to modifiy my project to work with DMA on the SDIO interface. Without DMA the system works fine. Then I modified my Cube settings to DMA and set the access functions to Write_DMA and Read_DMA. Now the system starts up and after the 7th access to HAL_SD_CheckReadOperation() systems hangs on:

while((__HAL_SD_SDIO_GET_FLAG(hsd, SDIO_FLAG_RXACT)) && (timeout > 0))

{

    timeout--;  

}

Accesses are:

- f_mount, find_volume, check_fs, move_window, SD_read, BSP_SD_ReadBlocks_DMA -> ok

- f_mount, find_volume, check_fs, move_window, SD_read, BSP_SD_ReadBlocks_DMA -> ok

- f_mount, find_volume, check_fs, move_window, SD_read, BSP_SD_ReadBlocks_DMA -> ok

- f_open, folow_path, dir_find, move_window, SD_Read, BSP_SD_ReadBlocks_DMA -> ok

- f_read, SD_Read, BSP_SD_ReadBlocks_DMA -> ok

- f_read, get_fat, move_window, SD_Read, BSP_SD_ReadBlocks_DMA -> ok

- f_read, SD_Read, BSP_SD_ReadBlocks_DMA -> ok

- f_read, SD_Read, BSP_SD_ReadBlocks_DMA -> fail

Interrupt is fired in according to the accesses.

I searched all the forum around but has no clue.

#dma #sdio #sd #fatfs #stm32
3 REPLIES 3
anio1491
Associate II
Posted on October 25, 2016 at 14:12

Hi,

I have the same problem. Did you find any solution?

Regards,

Andreea

sheyong5499
Associate II
Posted on October 27, 2016 at 04:25

Hi,

I have experience that before, and it is caused by the interrupt priority.

Try to make sure the DMA interrupts have the lower priority compared to your SDIO interrupt.

Hope it helps :)

slimen
Senior
Posted on October 27, 2016 at 15:18

Hello,

Please follow this answer from ST team in this [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/STM32L4%20STM32Cube%204.14%20SDMMC%20FATFS%20DMA%20TX%20RX%20hang&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=173]thread. Then, confirm if your problem is resolved or not .

''

First of all, the SD specification don't allow simultaneous Tx transfer and RX transfert,  they must be sequetially enabled.

So for the DMA used with SD, there is only one direction at a time and not both Tx and Rx. So we should  reconfigure the DMA channel/stream before each DMA read or write on SD.

We note that it is not possible to use a DMA channel for each transfer , because once DMAEN bit is set, the channel that has the highest priority will be automatically selected.

''

Regards