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

determine the root directory sector

 
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

determine the root directory sector
PostPosted: Mon Mar 28, 2005 12:54 am     Reply with quote

hi,
i want to determine the count root directory sector &
i think i must count it as follow:
RootDirSectors = (BPB_RootEntCnt * 32) / BPB_BytsPerSec;
but the in the "Microsoft Extensible Firmware Initiative
FAT32 File System Specification" wrote this:
RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec � 1)) / BPB_BytsPerSec;
could some one tell me why they plus the (BPB_RootEntCnt * 32) with (BPB_BytsPerSec � 1)?

i also see the 128 mmc card with winhex do the following formula on this Specification"
for count the FirstDataSector but as i guess the answer is wrong (it show one sector more than expect)

thanks.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Mar 28, 2005 7:27 am     Reply with quote

Quote:
RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec � 1)) / BPB_BytsPerSec;
could some one tell me why they plus the (BPB_RootEntCnt * 32) with (BPB_BytsPerSec � 1)?
This seems like a methode to make sure the division is always ceiling the result. Without this addition the division command would give an integer result where the fraction part is thrown away. By adding (BPB_BytsPerSec � 1) the result will always be 1 higher, except for the special case where the fraction is exactly zero.

Quote:
i also see the 128 mmc card with winhex do the following formula on this Specification"
for count the FirstDataSector but as i guess the answer is wrong (it show one sector more than expect)
I think part of your post is missing here. What formula?
nader



Joined: 29 Aug 2004
Posts: 12

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

PostPosted: Mon Mar 28, 2005 11:06 am     Reply with quote

hi,
thanks for your excellent answer.
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?

can i use all computation for fat in integer variable?(not float)

could you please tell me where can i find the some example code for fat16 for mmc card?

thanks alot.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Mar 28, 2005 11:58 am     Reply with quote

nader wrote:
hi,
thanks for your excellent answer.
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?

can i use all computation for fat in integer variable?(not float)

could you please tell me where can i find the some example code for fat16 for mmc card?

thanks alot.


You certainly would not want to use float! Think about it, you wouldn't have factional numbers to access a sector, cluster, or byte would you.

Remember that ints for CCS are only 8 bits. You need to use a variable type that is large enough to hold the data.

Where can you find it? You might try searching!
http://www.ccsinfo.com/forum/viewtopic.php?t=22326&highlight=fat16
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