PIC SD FAT reading speed

Hi, i'm new in P18 programming, so i'd like to know how much time does it take reading a byte from a file (in a FAT16 SD card) with a P18 clocked at 32Mhz using libraries provided by common languages such as C or similar.

Thank you

Reply to
merco
Loading thread data ...

On a sunny day (Wed, 10 Oct 2007 23:12:38 -0700) it happened merco wrote in :

There are many different speed type SD cards. And many ways to read an SD card (4 bits, one bit SPI). FAT16 has nothing to do with it exceet for when you need to look up where the data is.

Reply to
Jan Panteltje

i think is a standard one bit SPI...

Reply to
merco

On a sunny day (Thu, 11 Oct 2007 03:41:39 -0700) it happened merco wrote in :

Even then there are several possible implementations of that, Anyways, look at how many IO changes you need for a block, and the number of clock cycles the IO operation needs. That gives you a time per bit, per data word, and then you can see if that is faster then the card's read spec in SPI. Here I have some C source for SPI, you can see how many IO accesses are required.

formatting link
This was written by somebody else, is GPL (note the license), and modified by me for a project. The other person later wrote a much faster version. So it depends a lot on your code too. This one works 100% fine for me with 1GB SD cards, I have measured read and write speed on a 200 MHz MIPS processor, but cannot remember what it was. OK, lemme see between 150 and 190 KByte / second read speed on a cheap card. Some overhead as I read via webserver.

Reply to
Jan Panteltje

The first byte will take a while, successive bytes are faster.

Simplified, to get a byte from a file, you need to look into the file directory, comparing file names, possibly following a chain of subdirectories (which are a kind of file).

That will give you the start cluster of your file. You then have to follow a chain of pointers in the FAT to get the actual cluster on the disk your byte is in. Finally then need to read a whole sector and extract your byte.

In the process you have also read the other 511 bytes of that sector, have knowledge of the whereabouts of the other sectors of the cluster and can, with a single step along the FAT get at the next cluster of the file, etc.

The speed with which you can access a random byte mostly depends on how much memory you have spare to cache directory and FAT data.

The speed you can actually communicate with the SD card is likely to be limited by the SPI controller clock - probably 32MHz/4.

Kind regards,

Iwo

Reply to
Iwo Mergler
Reply to
Brendan Gillatt

well, i'm going to use

formatting link
this compilers to test my application. They have built in sd/mmc fat16 routines.

Reply to
merco

On a sunny day (Thu, 11 Oct 2007 23:16:33 +0100) it happened Brendan Gillatt wrote in :

I have put Linux ext2 filesystem on the SD card.

Reply to
Jan Panteltje
Reply to
Brendan Gillatt
Reply to
Brendan Gillatt

C18.

Newsgroups are priceless. A bad word of mouth, can save a lot of pain. Been looking in at that compiler site for a couple of years. I can ignore it now. Ta!.

Reply to
john jardine

On a sunny day (Fri, 12 Oct 2007 23:10:08 +0100) it happened "john jardine" wrote in :

I wrote, in my CP/M days, some small C routines to read files from PC FAT16 floppies, and write files to those. The only restriction was that I had no sub-directory support IIRC. You can find it here: ftp://panteltje.com/pub/ms_fat.bz2 Or, unzipped if you are MS windows user: ftp://panteltje.com/pub/ms_os/

Still some of the code may be of help if you want to find out and write FAT16 stuff.

I wrote it in C80 (Software Toolworks C compiler), a very simple C compiler. Untar this with tar -jxvf ms_fat.bz2.

Ignore the s14_...() routines, those are related my Z80 CP/M clone that you can find here:

formatting link

Reply to
Jan Panteltje

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.