Re: PIC SD FAT reading speed



merco wrote:

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

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

.



Relevant Pages

  • Re: The 9997th file specific DOSFS problem
    ... Thought it is already using 32 KB sector size. ... The 512 bytes "tiny cache" for the FAT is very intersting. ... and should not be confused with the cluster ...
    (comp.os.vxworks)
  • Re: Embedded RTOS - features poll
    ... you get two or more sector writes for each file write operation. ... You only search and update the FAT when ... add a new cluster. ... directory entry for the involved log file. ...
    (comp.arch.embedded)
  • Re: Embedded RTOS - features poll
    ... you get two or more sector writes for each file write operation. ... You only search and update the FAT when ... add a new cluster. ... FAT entry, you only need to start from the FAT sector ...
    (comp.arch.embedded)
  • Re: Implementing NVMHCI...
    ... What about FAT? ... "cluster size" in an FS is totally different from sector ... size in FAT is absolutely trivial to do: it's really purely an allocation ... The hardware sector size is very different. ...
    (Linux-Kernel)
  • Re: Embedded RTOS - features poll
    ... If the FAT ... lowest freed cluster from the last file delete. ... all the clusters on a 32GB SDHC card. ... That's about 32768 512-byte sectors. ...
    (comp.arch.embedded)