cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 SDIO continuos stream

felipe2
Associate III
Posted on July 23, 2015 at 11:02

Hi,

For the past few days I have been trying to get data written to an SDHC card at a constant rate of 1.2MBps without any success. I have based my SDIO driver on Clive's example, which was posted somewhere else in the forum, and so far I can write data to the SD card but not in a continuous stream. I also know that I'm achieving >3MBps data rate writing to the SD card because I can get it to save 16384 bytes in 5ms(checked with oscilloscope). To test the continuous data stream I did the following: -pre allocated files (FATFS) and then write to sectors in raw format (no filesystem overhead); -I use the systick to set a flag for new data ready every 5ms; -I write a block(16384bytes) of data to the sd card; Note:Each block has only 1 value in it which is the current block number. All the other values in the block are zeroed. This is to help check data integrity when reading the data in a PC. Below are snippets of my code:

MAIN.C 
while(ssect<656448)
{
if(data_ok)
{
data_ok=0;
res = disk_write(fs.drv, (uint8_t *)&bufferA[0], ssect , 32);
GPIO_ResetBits(LEDPORT,REDLED);
ssect+=32;
write_ok=1;
}
}
SYSTICK
uint32_t block=0;
uint8_t write_ok=1,data_ok=0;
void SysTick_Handler(void)
{
milli++;
if(milli==50)
{
milli=0;
if(write_ok==1) {
*((uint32_t *)&bufferA[0]) = block++;
data_ok=1;
write_ok=0;
}
else {
GPIO_SetBits(LEDPORT, REDLED);
block++;
}
}
TimingDelay_Decrement();
}

So, the problem that I'm seeing is that SD card busy delays are causing some blocks not being written to the card. I tried increasing the period between writes to 50ms(instead of 5ms) and I still get the same problem. I think this may be a buffer related issue but with the current PCB I'm limited to the internal MCU SRAM (128K). Has anyone successfully managed to stream 4GB @ 1.2MBps reliably using STM32 MCUs with SDIO?(Basically a very large amount of data at a quite high data rate) If so, could you share your experience? What is the maximum reliable continuous data stream anyone has achieved with only 128K of buffer? Ps1:In the meanwhile will try implementing a double buffering scheme to see if that makes any significant improvement. Ps2:I have tried a couple of different SD cards(class 10) from different manufacturers as I'm aware that SD cards are different but still got the same results + I would like to make something that is not so dependent on the type of SD card used. Thanks, Felipe #stm32 #dma #fatfs #sdio #sd
0 REPLIES 0