CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

fat16

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nader



Joined: 29 Aug 2004
Posts: 12

View user's profile Send private message Send e-mail

fat16
PostPosted: Fri Mar 25, 2005 2:52 am     Reply with quote

hi,
i need some document that explain every detail of the fat16.i want it for mmc card.
thanks alot.
LomasS
Guest







PostPosted: Fri Mar 25, 2005 4:06 am     Reply with quote

I couldn't find the link on Microsoft, but this is the document from elsewhere:
http://staff.washington.edu/dittrich/misc/FatFormat.pdf

Steve.
ik1wvq



Joined: 21 Feb 2004
Posts: 20

View user's profile Send private message

PostPosted: Sat Mar 26, 2005 7:28 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 30, 2005 6:38 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 30, 2005 4:32 pm     Reply with quote

Also check the Code Library forum on this website for some example implementations.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group