2016-06-06 11:02 PM
Hi,
I am working on STM32L4xx MCU. I have connected MicroSD card of 8GB size over SDMMC interface. And I am using DMA for write to the SD card.Now, DMA is used to keep the MCU free during that time of data transfer. But what I saw is, after initiating the DMA for data transfer the BSP code is waiting for transfer complete of DMA by calling ''HAL_SD_CheckWriteOperation()'' function, which will keep MCU busy. And thus it defeats the purpose of DMA!!Is this wait is really required? Can't we simply initiate the DMA transfer and avoid this wait?Please help me to understand this.Thanks,Dhaval #sdmmc1 #microsd #dma #stm322016-06-07 12:54 AM
Hi Dhaval,
do you read this https://my.st.com/c964d235 ? Petr2016-06-07 01:16 AM
Hi Petr,
Thanks for you quick reply.I read that post. According to it, to enable DMA read/write operation for SD card I need to modify SD_read()/SD_write() functions in sd_diskio.c file. I already modify SD_write() function accordingly, but not SD_read() function, as firmware is just writing to the SD card but not reading back from it. So DMA for read is not required in my case.Now, the problem is, the BSP implementation for DMA write operation waits for transfer to complete, by calling ''HAL_SD_CheckWriteOperation()'' function. And thus CPU will remain busy till transfer completes, and that defeats the purpose of DMA!So, what is the importance of that wait for transfer to complete operation? And can I disable it?Regards,Dhaval2016-06-07 04:40 AM
Hi dhavalv,
I report your feedback regareding BSP_SD_WriteBlocks_DMA() function. 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¤tviews=107]thread -Hannibal-2016-06-07 05:53 AM
You have to serialize access to the SD Card.
You have to wait for the current command to complete and the FIFO to empty. You have to pass a success/failure message to the file system. There are a number of ways to do this without spin-loops. One could make a complicated asynchronous driver stack, tends to be too complex for most people. Perhaps an easier way is to use an RTOS, and put all the file system / disk io into a thread of it's own, servicing requests, and yield while waiting.