free 8051 Microcontroller Projects AVR PIC Microcontroller Projects Tutorials Ebooks Libraries, interfacing tutorials, lcd tutorial, stepper motor, dc motor 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems

 
8051 microcontroller 8051 microcontroller
Forums

Go to page  [1] 2 3
Moderators: Ajay, Junied , abbas1707, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph
Author Post
jameslys
Tue Sep 02 2008, 07:00AM
 User Offline
Registered Member #3809
Joined: Sun Sep 02 2007, 06:45AM

Posts: 24
Thanked 0 times in 0 posts
can anyone tell me how to access the fat16 in sd card using spi?
where to find the fat16 accessing details?

Back to top


Ajay
Tue Sep 02 2008, 02:01PM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4042
Thanked 753 times in 712 posts
Jameslys, are you able to get your card working?

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


jameslys
Tue Sep 02 2008, 04:48PM
 User Offline
Registered Member #3809
Joined: Sun Sep 02 2007, 06:45AM

Posts: 24
Thanked 0 times in 0 posts
my card is successfully initialized, can read the CID register. i try to read the address 0x00 of a fat16 formatted card, it returns all 0. i dont know why.
Back to top


Ajay
Wed Sep 03 2008, 01:57AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4042
Thanked 753 times in 712 posts
you have to read sectors, not addresses..

I hope you know the complete structure of how FAT file system is organized, so once you read the MBR of card, you will come to know the location of root directory.

Official information on FAT16 by Microsoft:

Better explained.. (recommended)
FAT16 Structure Information

[ Edited Wed Sep 03 2008, 02:01AM ]

www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


jameslys
Wed Sep 03 2008, 03:21AM
 User Offline
Registered Member #3809
Joined: Sun Sep 02 2007, 06:45AM

Posts: 24
Thanked 0 times in 0 posts
some of the address contains more than one byte data, such as maximum root directories and sectors per FAT, which are containing 2 bytes data. For spdat, one byte data is received and store each time, i use array to store the data. how to i combine 2 different array elements to calculate the sector address?
Back to top


Ajay
Wed Sep 03 2008, 03:57AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4042
Thanked 753 times in 712 posts
i give you example to combine two bytes to form 16-bit value.

CODE:
unsigned char byte1 = 0x28;
unsigned char byte2 = 0x35;
unsigned int combined;

combined = byte1;
combined = (combined << 8) | byte2;
//combined will now have value 0x2835
 


www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top



This post has been thanked 1 time
 nismo 
jameslys
Wed Sep 03 2008, 04:14AM
 User Offline
Registered Member #3809
Joined: Sun Sep 02 2007, 06:45AM

Posts: 24
Thanked 0 times in 0 posts
thanks a lot
Back to top


jameslys
Wed Sep 03 2008, 04:31AM
 User Offline
Registered Member #3809
Joined: Sun Sep 02 2007, 06:45AM

Posts: 24
Thanked 0 times in 0 posts
if i need to combine 4 bytes to form a 32-bit value, is it like that?

unsigned char byte1 = 0x28;
unsigned char byte2 = 0x35;
unsigned char byte3 = 0x30;
unsigned char byte4 = 0x26;
unsigned int combined;

combined = byte1;
combined = (combined << 8) | byte2;
combined = (combined << 8)| byte3;
combined = (combined << 8) | byte4;

is the code above correct? Can i declare combined as unsigned long combined
And combine the 3 code sentences as:?
combined = (combined << 24) | byte2 | byte3 | byte4;
Back to top


Ajay
Wed Sep 03 2008, 05:57AM
Rickey's World Admin

 User Offline

Registered Member #1
Joined: Fri Feb 24 2006, 04:56AM

Posts: 4042
Thanked 753 times in 712 posts
the first code is fine..

you can shorten it like this..
CODE:
combined = byte1;
combined = (combined << 24) | (byte2<<16) | (byte3<<8) | byte4
 


www.rickeyworld.info
If you feel satisfied with the user's forum reply please click on the thank button.

Obey forum rules!
Respect others!
Back to top


jameslys
Fri Sep 05 2008, 06:23PM
 User Offline
Registered Member #3809
Joined: Sun Sep 02 2007, 06:45AM

Posts: 24
Thanked 0 times in 0 posts
If the fat16 is fragmented, how to get the next cluster value after i accessing the starting cluster? If the current cluster is the end of file, is it will show that the next cluster is FFF8 - FFFH? If the is multiple files in the fat16 farmatted sd card and a structure is declared for user selection later, how to add the root directory of each files into the structure by skipping the empty entries. And how to determine that current sector read is the last sector in the cluster? is it by comparing to the size of cluster?

[ Edited Fri Sep 05 2008, 06:27PM ]
Back to top


Go to page  [1] 2 3  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

8051 Microcontroller Projects 8051 AVR tutorials PIC microcontroller, 8051 assembly language programming electronics and communication ECE CSE pdf ebooks library BE final year project ideas Embedded systems