AnsweredAssumed Answered

FIFO error while initializing SD card write over DMA

Question asked by Campbell.Aaron.001 on Dec 8, 2015
Latest reply on Dec 15, 2015 by Campbell.Aaron.001
I have an STM3240G-EVAL and I'm using the HAL drivers from STM32CubeF4 to access the SD card. It can read data, but it hits this error the first time it attempts a write.

I call BSP_SD_WriteBlocks_DMA(), which calls HAL_SD_WriteBlocks_DMA(), which does a few things and finishes by calling SDIO_DataConfig, as follows:

  sdio_datainitstructure.DataTimeOut   = SD_DATATIMEOUT;
  sdio_datainitstructure.DataLength    = BlockSize[=512] * NumberOfBlocks[=1];
  sdio_datainitstructure.DataBlockSize = SDIO_DATABLOCK_SIZE_512B;
  sdio_datainitstructure.TransferDir   = SDIO_TRANSFER_DIR_TO_CARD;
  sdio_datainitstructure.TransferMode  = SDIO_TRANSFER_MODE_BLOCK;
  sdio_datainitstructure.DPSM          = SDIO_DPSM_ENABLE;
  SDIO_DataConfig(hsd->Instance, &sdio_datainitstructure);

Prior to SDIO_DataConfig(), DMA2->HISR is clear, but this call makes both TCIF6 and FEIF6 get set. The result is that the interrupt handler gets called, a FIFO error is detected, and my error callback function is invoked.

Why might this failure be happening? I could suspect the hardware, since I've had several complicated issues using other drivers to access the SD card.

In case it matters, I use BSP_SD_Init() to initialize the SD card. Also, it works fine in polling mode, as long as I only read/write one block at a time. Writing multiple blocks can get me a SD_CMD_RSP_TIMEOUT error (I'd love to know why that might happen as well, if anyone knows).

Outcomes