cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 STM32Cube 4.14 SDMMC FATFS DMA TX RX hang

isjeon
Associate II
Posted on June 12, 2016 at 10:04

Hi.

FATFS with polling mode is OK(Except TX uderrun error when interrupt).

When using DMA, 

FATFS works OK with TX DMA only. (DMA interrupt priority should be lower than SD interrupt).

FATS works OK with RX DMA only.

But when enabling both TX/RX DMA, the RX DMA parts works OK.

Mounting and file listing is OK.

But TX DMA  runs ,the chip is hang on while loop with red color below.

HAL_SD_ErrorTypedef HAL_SD_CheckWriteOperation(SD_HandleTypeDef *hsd, uint32_t Timeout)

{

  HAL_SD_ErrorTypedef errorstate = SD_OK;

  uint32_t timeout = Timeout;

  uint32_t tmp1, tmp2;

  HAL_SD_ErrorTypedef tmp3;

  /* Wait for DMA/SD transfer end or SD error variables to be in SD handle */

  tmp1 = hsd->DmaTransferCplt; 

  tmp2 = hsd->SdTransferCplt;

  tmp3 = (HAL_SD_ErrorTypedef)hsd->SdTransferErr;

    

 

while (((tmp1 & tmp2) == 0) && (tmp3 == SD_OK) && (timeout > 0))

  {

    tmp1 = hsd->DmaTransferCplt; 

    tmp2 = hsd->SdTransferCplt;

    tmp3 = (HAL_SD_ErrorTypedef)hsd->SdTransferErr;

    timeout--;

  }

3 REPLIES 3
Leo_Panda
Associate III
Posted on September 12, 2016 at 13:57

I also had have problems if i use dma bidirectional. The reason is the wrong configuration in HAL-library. In HAL_SD_ReadBlocks_DMA (file stm32l4xx_hal_sd.c) and HAL_SD_WriteBlocks_DMA one have to disable dma and enble it after configurate the adress and direction etc. otherwise you can not modify the ccr register. that is why id dibn't work for bidirectional since the registers could only be written one time before it was enabled.

the hal library is realy faultily, also the configuration of blockszie register was wrong. i hope we will get a new version soon...

Walid FTITI_O
Senior II
Posted on October 11, 2016 at 11:46

Hi embedholic, 

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.

-Hannibal-
anio1491
Associate II
Posted on October 25, 2016 at 14:47

Hi,

I have exactly the same problem. Could you suggest a solution for this?