SD CARD writing Delay!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-11 3:03 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-11 4:50 AM
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 DISKIOUp vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-12 8:45 PM
''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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-01-13 1:05 AM
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.