cancel
Showing results for 
Search instead for 
Did you mean: 

SD CARD writing Delay!

Javad
Associate III
Posted on January 11, 2016 at 12:03

hi

I am writing to Micro SD cards over SDIO. What I have noticed is that sometimes, the write cycle seems to take longer for no reason. And the longer cycles are almost exactly the same length. I use a LED to show writing time:

BufferSize=65536;

for(count=0;count<5000;count++)

{

res = f_write(&fil, buff, BufferSize, &br);

GPIO_ToggleBits(GPIOF,GPIO_Pin_10);}

how can I solve this problem? following image that I save with my oscillator shows writing delays.

0690X0000060MoKQAU.gif

3 REPLIES 3
Posted on January 11, 2016 at 13:50

Either the file system is reading/writing other sectors managing it's own structures, or the media is managing it's internal blocks.

I guess if I wanted to decompose this further I'd toggle different GPIOs for read/write paths in DISKIO

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Javad
Associate III
Posted on January 13, 2016 at 05:45

 ''if I wanted to decompose this further I'd toggle different GPIOs for read/write paths in DISKIO''

 

it's not clear for me how can I do it! I read DISKIO.c and DISKIO.h but I couldn't find where GPIOs for read/write are defined.

in addition I made confuse! different GPIOs for read and write? is it possible? I'm pleased if you explain some more.

AvaTar
Lead
Posted on January 13, 2016 at 10:05

You got that wrong. There are no ''GPIOs defined for read and write''.

Clive suggests to initialize two GPIOs (any one you like, and which is free on your hardware), and toggle them when you start and finish reading and writing, respectively.

Attaching a scope to this pins, you can trace the actual timing of you SD read and write accesses.

BTW, I think you cannot avoid those delays. They happen when the SD card firmware needs to erase a block before writing to it, which takes several milliseconds.

If that breaks your application, you might need to implement some buffering and read-ahead mechanism.