2019-05-09 12:53 PM
All,
I am getting an issue when attempting to write to the SD card using a DMA burst transfer. I am transferring bytes to words in burst sizes of 16 beats to 4 beats respectively. I am using the full FIFO and direct mode is disabled. Memory is incrementing and the peripheral is not.
After debugging it has become clear that my transmit complete and FIFO error both trip as I am configuring the SD data path state machine, which happens in the application code after I have already enabled the SD and DMA for the transfer. This does not happen when I set up the read in a similar fashion. This happens right after this line of code is executed
/* Write to SDMMC DCTRL */
MODIFY_REG(SDMMCx->DCTRL, DCTRL_CLEAR_MASK, tmpreg);
I am configuring the SD as follows.
/* Configure the SD DPSM (Data Path State Machine) */
config.DataTimeOut = SDMMC_DATATIMEOUT;
config.DataLength = BLOCKSIZE * NumberOfBlocks;
config.DataBlockSize = SDMMC_DATABLOCK_SIZE_512B;
config.TransferDir = SDMMC_TRANSFER_DIR_TO_CARD;
config.TransferMode = SDMMC_TRANSFER_MODE_BLOCK;
config.DPSM = SDMMC_DPSM_ENABLE;
Please let me know if you see any issues or have any suggestions.
I should also say that this is the same way that I configure the SDMMC for IT blockwrites, and IT blockwrites work without issue.
I should also show how I configure the SDCard, once again, this works for IT blockwrites.
hsd.Instance = SDMMC2;
hsd.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
hsd.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE;
hsd.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
hsd.Init.BusWide = SDMMC_BUS_WIDE_1B;
hsd.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
hsd.Init.ClockDiv = SDMMC_TRANSFER_CLK_DIV
/* Configure the SDMMC peripheral */
Init.ClockEdge = hsd.Init.ClockEdge;
Init.ClockBypass = hsd.Init.ClockBypass;
Init.ClockPowerSave = hsd.Init.ClockPowerSave;
Init.BusWide = SDMMC_BUS_WIDE_4B;
Init.HardwareFlowControl = hsd.Init.HardwareFlowControl;
Init.ClockDiv = hsd.Init.ClockDiv;
SDMMC_Init(hsd.Instance, Init);
I should also say that reading and writing seemingly work, in small scales, but when I implement these functions into a larger codebase, the data being read out is jumbled. This implies that my read is somehow broken as well, but that I am not catching it with any error signal. I have seen that issues that don't throw errors may be a symptom of an AHB issue. If someone more informed than me can see that this may be an issue, could you please elaborate?
Thanks!
Solved! Go to Solution.
2019-05-11 11:43 AM
I have sorted out the issue here. The FIFO error can be safely ignored. The issue with the memory jumble was the size of the file that I was transferring. I was sending a 480,000 byte file all at once. This is impossible with the DMA even with peripheral flow control and "writeblocks". The maximum size is actually around half of that. Half of my images were valid and the other half was missing. I have other questions related to this same topic with additional explanation on how to ensure that the set-up is correct.
2019-05-11 11:43 AM
I have sorted out the issue here. The FIFO error can be safely ignored. The issue with the memory jumble was the size of the file that I was transferring. I was sending a 480,000 byte file all at once. This is impossible with the DMA even with peripheral flow control and "writeblocks". The maximum size is actually around half of that. Half of my images were valid and the other half was missing. I have other questions related to this same topic with additional explanation on how to ensure that the set-up is correct.