AnsweredAssumed Answered

STM32L4 STM32Cube 4.14 SDMMC FATFS DMA TX RX hang

Question asked by embedholic on Jun 12, 2016
Latest reply on Oct 25, 2016 by oltean.andreea
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--;
  }

Outcomes