I recently purchase Progressive Resources FAT file system. The code writes to a buffer and then writes out to an SD card when the buffer is full. This all works great but when writing out to the card I get a delay of around 250ms. It seems as though this is supposed to happen because of the delays in searching out a sufficient sector and what not. Oh, I run my spi bus at 5Mhz. My problem is I don't want my processor (18f6720) waiting on that transfer it has to maintain its timing loops at 2 ms and 10 ms. Now I have tried messing with the interrupts but if I run the SD card in the background and it gets interrupted during the big buffer write, it doesn't successfully store the data. I have tried disabling the rtcc interrupt (my timing loops) but that doesn't seem to work. Finally I've tried to prioritize the spi interrupt to see if that would accomplish anything but it didn't. Does any out there have any ideas.
Thanks in advance.
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
Posted: Wed Dec 07, 2005 5:02 pm
Qualifier first: I have not used the software you are talking about. I have written my own SD/MMC drivers and FAT system ported from various bits of code on the web and in the forum library.
The times you are talking about are WAY too long. The only real "long" time required when talking to these cards is the initial power on time where the card can take 500ms (actually takes much less) to transition to the ready state. According to the data sheet a read/write access should "typically" be 1ms and 2ms worst case. My testing shows it to be significantly less than 1ms. If your circuit powers down the SD/MMC card (physically removes power) then you would end up going through this power up sequence each time you accessed the card.
SD/MMC cards go to "sleep" after 5ms of inactivity and it can "take some" to wake up. I have no idea what "some time" is meant to be (I assume it is the 1 to 2ms mentioned previously). All the cards I have tested (about 10 different manufactures) have all responded immediately.
Creating a file can take a 10s of milliseconds (but much less than 250ms) as the PIC has very limited memory so the fat and directory has to be read for each operation and updated after each operation. The PIC does not have sufficient memory to "cache" this as would typically happen on a PC operating system. I am working on a design that requires new data to be logged at a sample rate of 50Hz writing 12 bytes per sample. In order to achieve this I am adding a FRAM to enable me to cache the FAT and the entire current cluster of the target file plus act as a ring buffer to cache incoming data while accessing the SD/MMC card. _________________ Regards, Andrew
I have looked at the power being supplied to the card and even hooked up an external power supply. Still hasn't fixed the problem. It is Progressive's fputc_() function that takes so long. I will do some more digging but I am in the middle of another project now. Has anyone else had a similar problem?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum