2016-06-12 01:04 AM
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--; }2016-09-12 04:57 AM
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...2016-10-11 02:46 AM
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-2016-10-25 05:47 AM
Hi,
I have exactly the same problem. Could you suggest a solution for this?