View previous topic :: View next topic |
Author |
Message |
nader
Joined: 29 Aug 2004 Posts: 12
|
fat16 |
Posted: Fri Mar 25, 2005 2:52 am |
|
|
hi,
i need some document that explain every detail of the fat16.i want it for mmc card.
thanks alot. |
|
|
LomasS Guest
|
|
|
ik1wvq
Joined: 21 Feb 2004 Posts: 20
|
|
Posted: Sat Mar 26, 2005 7:28 am |
|
|
hi,
fat16 implementation is long and difficult..
I use a trivial,stupid but simple mode to store the data into a "file" in MMC, and retring its by a PC:...
* PC SIDE *
- with Visul Basic run a program like this:
sector1$ = "FREE" ' 512 bytes sector
For n = 1 To 512 - 4
sector1$ = sector1$ & Chr$(255)
Next n
Open "MMC111.dat" For Output As #1
For n = 1 To num_sector
Print #1, sector1$;
Next n
Close #1
this produce a file with all 512 blocks starting with "FREE" word.
- copy this file into the MMC card with a USB MMC adapter
(better if the file lenght is equal to the MMC size. if not, fill the MMC with garbage files.
Now place the MMC card into the socket of your PIC board.
*PIC side*
-scan the mmc card, reading the first 4 bytes of each sector, and stop when you find the "FREE" word.
- make a 512 byte block starting with "USED" followed by a sequential sector counter (from 0 to ...) and followed by your data.
- write it into the MMC . the next time you must write a block, start searching for "FREE" from this just writed block (you dont waste time).
*PC SIDE*
When you need to transfer the MMC data to the PC:
- copy the file from the MMC to the PC with a USB adaptor
- with a VB program read all 512 bytes file blocks
- ignore the blocks starting by "FREE"(=not used)
- VERIFY ABSOLUTELY what your sector counters are in sequence (FAT16 dont guarantee what blocks are placed sequentially into physical space)
- if necessary (never happen on my experience) sort its
- remove the "USED + sector counter" from your blocks data ..
- to erase the data and reconditioning the MMc for the next use, simply rewrite the original file into the MMC...
(In my project, i manage all this PC operation under an unique VB program, trasparent to the user)
It is all .. few bytes and the trick work perfectly in my projects.
it is all.
Enjoy .
MAuro ik1wvq |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Mar 30, 2005 6:38 am |
|
|
Quote: | as i understood when use the formula plus the (BPB_BytsPerSec � 1) so we don't need any more to rounds up the RootDirSectors.is that right? | Right.
Quote: | can i use all computation for fat in integer variable?(not float) | I'm not sure about all FAT computations, but this one you can do with normal integers.
Quote: | could you please tell me where can i find the some example code for fat16 for mmc card? | Use the search function of this forum and you'll find several pointers. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Mar 30, 2005 4:32 pm |
|
|
Also check the Code Library forum on this website for some example implementations. |
|
|
|