DMA FIFO Error When DMA Enabled for Write, Not Read, While Configuring SDMMC
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!
