AnsweredAssumed Answered

STM32F4 SDIO DMA FIFO Error

Question asked by lerch.david on Dec 16, 2013
Latest reply on Sep 10, 2017 by li jinqiu
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:

01.unsigned int numBytes = 512;
02. 
03.SDIO_DTIMER = 0xFFFFFFFF;
04. 
05.DMA2_LIFCR = 0xF400000;
06. 
07.DMA2_S3PAR = (uint32_t) &SDIO_FIFO;
08.DMA2_S3M0AR = (uint32_t) data2;
09. 
10.// PFCTRL = 1
11.// DIR = 01 (MEM->PERIPH)
12.// MINC = 1
13.// PSIZE = 10 (Word)
14.// MSIZE = 10 (Word)
15.// PL = 11 (Very High)
16.// PBURST = 01 (INCR4)
17.// MBURST = 01 (INCR4)
18.// CHSEL = 100 (CH4)
19.DMA2_S3CR = 0x8A35460;
20. 
21.// FTH = 11 (Full FIFO threshold)
22.// DMDIS = 1
23.// FEIE = 1
24.DMA2_S3FCR |= 0x87;
25. 
26.// EN = 1
27.DMA2_S3CR |= 0x1;
28. 
29.SDIO_DLEN = numBytes;
30. 
31.// DMAEN = 1
32.// DBLOCKSIZE = 1001
33.SDIO_DCTRL = (SDIO_DCTRL & ~0xFF) | 0x98;
34. 
35.SDIOSendCommand(25, 0, SDIO_RESPONSE_SHORT);
36.res = SDIOCheckResponse1Errors(25, NULL);
37. 
38.if (res != SDIO_ERROR_NONE)
39.    printf("ERROR!\n");
40. 
41.// DTEN = 1
42.SDIO_DCTRL |= 0x1;
43. 
44.uint32_t lisr1 = DMA2_LISR;
45. 
46.Delay(0xF);
47. 
48.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!

Outcomes