cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO transfers gets stuck

yzhang1985
Associate III
Posted on September 14, 2014 at 13:13

Hi everyone. I'm having trouble writing images from a camera to a microSD card on my STM32F4 Discovery board. The SD writes keep getting stuck in the HAL

 function, SD_DMA_RxCplt(). I'm using FAT_FS, so even though I'm writing, the file system book keeping still needs to read.

* Wait until SD transfer is complete */

while(hsd->SdTransferCplt == 0)

{

}

One huge clue is that this only happens when I set the SD clock to be faster than 1/12 of the AHB speed (168 MhZ). Similarly, if I turn off the DCMI capture interface, I can use any SD clock speed within spec.

This seems to be some issue with DMA. I'm using DMA2 for both the SDIO and camera interface, so could there be FIFO overflows or lost interrupts causing the SD read to never be completed? How can I fix that?

The camera clock is 16MhZ, so the maximum data rate is 16MiB/s (usually much less (< 2 MiB/s) since the images are JPEG). The DMA configuration is circular buffer,  no FIFO, 1 word burst. The SDIO  DMA configuration is FIFO, 4 word burst. I tried changing the camera DMA configuration to 4 word burst, but that didn't help. It also seems 4 word burst transfers for DCMI would be wrong because that would require the FIFO to be full before writing to memory, meaning incoming pixels might be dropped due to the FIFO being full?

#camera #dcmi #sdio #dma
2 REPLIES 2
Posted on January 20, 2015 at 15:42

Hi,

In fact, when the uSD is usedthe Camera module must be unplugged, this is due tothe shared pins between the two devices. Try to set the Camera STANDBY pin(to avoid conflict with SDCard detect pin)

/* Set the camera STANDBY pin */
BSP_IO_ConfigPin(XSDN_PIN, IO_MODE_OUTPUT);
BSP_IO_WritePin(XSDN_PIN, SET);

Regards, Heisenberg.
michaelisaev9
Associate II
Posted on February 07, 2016 at 15:41

Hi.

Check that interrupt priority of SDIO is higher than that of DMA handler.

DMA handler waits for SDIO interrupt to set complete flag.