Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

FatFS-writing to SD card performance

Status
Not open for further replies.

stevec

New Member
Hi all.
I'm currently using a Freescale MC9S08JM32 8 bit processor running at about 5MIPS to read and write data from/to an SD card. I'm using a bought in FAT16/32 filing system. I need to achieve at least 32kB/sec write speed to the card and have found that my current system takes about 6ms to do a sector write but takes 100mS to 200mS when it gets to a cluster boundary. The system uses one 512 byte buffer for everything. This periodic slowdown only gives me an average of 22kB/sec write speed which is not enough!
I have seen reference to people using the FatFs and TinyFatFs systems on this forum so wanted some idea of the speed of writing to card of these systems. I gather that the FatFs uses separate buffers for file handling and data. My existing system has to read FAT data every time it assigns a new cluster to the file and it is this searching for the next cluster (with reads from the card) that seems to slow things down. How does FatFs handle this? I would be grateful if any forum members have details of write speeds. I am attempting to record a .wav file at 16kHz 16 bit mono. Do I need to go to a better (16 bit) processor?
 

DirtyLude

Well-Known Member
Yes, there is a directory/FAT buffer and a read/write buffer for each open file in FatFS. Not in the tiny version, though. The Tiny version uses one buffer for everything.

I have not timed write operation, but write speed is more limited by the card interface than anything. There's some things you can do to tweak it. SD cards apparently will sustain better SPI transfer speeds than they will initialize with, so you can up the spi data rate after the card is initialized.
 

stevec

New Member
Thanks for the reply.

I up the data rate after initialisation to 12MHz, although most of my measurements are done at 6MHz. I found only marginal differences betwen the two. The max SPI speed I can achieve is 12MHz as this is the maximum my uC can run at (half bus speed).
Am I right in thinking that, even with two buffers (one data, one filing system), the FAT table still needs to be read into the file buffer to search for the next free cluster, and that the larger the number of files (or rather the more card space is used) then the longer this search takes? Therefore as far as using the TinyFatFs as opposed to FatFs, there is little speed advantage?

Has anyone out there done any write speed measurements?

I'm going to look at porting FatFs on to my uC over the next few days. Then maybe consider going for a PIC24 as there seems to be more online support for using this chip in this application. It may be that even at 5MIPS my processor just isn't fast enough. What tools are available for this chip - especially if they are free!!
 

DirtyLude

Well-Known Member
Sorry, can't help with anything else. I'm using FatFS on an embedded ethernet project and the access speed has never been critical enough to do any timing testing.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top