cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 SDIO DMA FIFO Error

alemariusnexus
Associate II
Posted on December 16, 2013 at 19:54

Hi,

I'm quite new to microcontroller programming, and I'm currently rolling my own library using STM32F4's SDIO peripheral. I'm currently having problems when I write data to a card using the DMA. My (heavily stripped down) testing code is the following:


unsigned 
int
numBytes = 512; 


SDIO_DTIMER = 0xFFFFFFFF;


DMA2_LIFCR = 0xF400000;


DMA2_S3PAR = (uint32_t) &SDIO_FIFO;

DMA2_S3M0AR = (uint32_t) data2;


// PFCTRL = 1

// DIR = 01 (MEM->PERIPH)

// MINC = 1

// PSIZE = 10 (Word)

// MSIZE = 10 (Word)

// PL = 11 (Very High)

// PBURST = 01 (INCR4)

// MBURST = 01 (INCR4)

// CHSEL = 100 (CH4)

DMA2_S3CR = 0x8A35460;


// FTH = 11 (Full FIFO threshold)

// DMDIS = 1

// FEIE = 1

DMA2_S3FCR |= 0x87;


// EN = 1

DMA2_S3CR |= 0x1;


SDIO_DLEN = numBytes;


// DMAEN = 1

// DBLOCKSIZE = 1001

SDIO_DCTRL = (SDIO_DCTRL & ~0xFF) | 0x98;


SDIOSendCommand(25, 0, SDIO_RESPONSE_SHORT);

res = SDIOCheckResponse1Errors(25, NULL);


if
(res != SDIO_ERROR_NONE)

printf
(
''ERROR!\n''
);


// DTEN = 1

SDIO_DCTRL |= 0x1;


uint32_t lisr1 = DMA2_LISR;


Delay(0xF);


uint32_t lisr2 = DMA2_LISR;

The transmitted data (data2) is defined like this:

1.
char
data2[2048] __attribute__((aligned(1024)));

I think I'm using the same DMA configuration as the Standard Peripheral Library, but when I check the value of lisr2 in line 48 in the debugger, I'm getting the FEIF3 flag set (FIFO error). According to the documentation, this can happen either when the DMA FIFO configuration is wrong - but I don't see what could be wrong with my code, also the error flag is not set directly after the transfer is started, because lisr1 in line 44 doesn't have this flag set -, or a FIFO overrun/underrun occurred, but there's no error flag set in SDIO_STA, and I wouldn't know why the FIFO overruns/underruns when the peripheral acts as a flow controller. Also, the data seems to be correctly transmitted to the SD card (at least the output of my logic analyzer looks good), despite the FIFO error being flagged. Any ideas? Thanks in advance! #stm32f4-sdio-dma-fifo-feif
2 REPLIES 2
alemariusnexus
Associate II
Posted on December 22, 2013 at 19:43

Anybody? Anything I could try to get more details as to why this error happens?

li jinqiu
Associate II
Posted on September 10, 2017 at 04:33

Hi,I also have this question. It can write  several times to the sdcard, then it stop at 'set block size for card' command with 'SDMMC_ERROR_CMD_RSP_TIMEOUT'