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
Sun Sep 07 2008, 09:49PM
 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?

Back to top


Ajay
Mon Sep 08 2008, 02:19PM
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 want you to try it on your own.. to see how FAT16 FS looks like

Download HxD (hex editor) from http://mh-nexus.de/en/
and view files in you MMC/SD. see how MBR is constructed. Check sector 0.
See how FAT is allocated in MMC. How files are linked and lot more

It will be a good working experience on FAT.

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


nismo
Tue Sep 09 2008, 12:30PM
 User Offline
Registered Member #9479
Joined: Thu Jul 31 2008, 09:03AM

Posts: 77
Thanked 1 time in 1 posts
yoyo, what is your progress. i have just started FAT16 yesterday. Feeling lost.. haha. Hope everything is fine. Good luck pal
Back to top


nismo
Tue Sep 09 2008, 12:55PM
 User Offline
Registered Member #9479
Joined: Thu Jul 31 2008, 09:03AM

Posts: 77
Thanked 1 time in 1 posts
Err, i have tested the software that Ajay has uploaded. Actually our data is represented in ANSIC. I wonder what is the connection of this with FAT. I remember that the offset of the FAT16 is 2 bytes only. But the HxD is more than that. But i have a better picture of how the file is being encoded. Thanks man...
Back to top


Ajay
Wed Sep 10 2008, 01:37PM
Rickey's World Admin

 User Offline

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

Posts: 4042
Thanked 753 times in 712 posts
Nismo,
FAT is a table that maintains the file structure of a disk. Theoretical knowledge always tells you things but you can understand those things better, if you can see them practically. So open the FAT16 specifications + your MMC drive in the software parallel.

To know things better, try doing this..
format your MMC drive in FAT16, create two small files abc.txt and efg.txt and see how they are stored in MMC sector vise.
think yourself as a controller and try to understand how would you read file from a given start sector that will solve all your problems.

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


nismo
Wed Sep 10 2008, 09:45PM
 User Offline
Registered Member #9479
Joined: Thu Jul 31 2008, 09:03AM

Posts: 77
Thanked 1 time in 1 posts
Oh yea, how come i never think of this. Thanks man
Back to top


nismo
Sat Sep 13 2008, 01:51AM
 User Offline
Registered Member #9479
Joined: Thu Jul 31 2008, 09:03AM

Posts: 77
Thanked 1 time in 1 posts
Do you have anyway to access a sector of the SD card? Any example? i mean access the sector. i have tried to write a code to access the sector in the sd card. the internal memory is not enough to accommodate my array as big as 512...

void readSector (unsigned long sector){
unsigned int count = 0;
unsigned char buf[SECTOR_SIZE];

sector += sectorZero;
sector *= 2;
setBlockLength ();
CMD (0xFF);
sendBlock ();
if(SPDAT == 0x00){
for(count = 0;count<SECTOR_SIZE;count++){
buf[count] = SPDAT;
}
}
if(buf[54]==0x46)
LCD_sendString ("F");

CMD(0xFF);
}


here is my code

[ Edited Sat Sep 13 2008, 11:18PM ]
Back to top


luckynumber
Sun Sep 14 2008, 01:43AM
 User Offline
Registered Member #9314
Joined: Sat Jul 26 2008, 05:44AM

Posts: 23
Thanked 0 times in 0 posts


this is MBR that i view from HxD

according to thr master boot record table

Offset Description Size
000h Executable Code (Boots Computer) 446 Bytes
1BEh 1st Partition Entry (See Next Table) 16 Bytes
1CEh 2nd Partition Entry 16 Bytes
1DEh 3rd Partition Entry 16 Bytes
1EEh 4th Partition Entry 16 Bytes
1FEh Executable Marker (55h AAh) 2 Bytes

the 1st partition entry should be at 1BEh, but from the HxD, the content of 1BEh is the ancii of 'o'

is my understanding correct?

[ Edited Sun Sep 14 2008, 02:14AM ]

Back to top


nismo
Sun Sep 14 2008, 07:46AM
 User Offline
Registered Member #9479
Joined: Thu Jul 31 2008, 09:03AM

Posts: 77
Thanked 1 time in 1 posts
But according to Mr Siew, that is not MBR but FAT Boot Record. If you use xp to format your sd card. There will be no MBR anymore. Anyway, it is told by Mr Siew...

[ Edited Sun Sep 14 2008, 07:49AM ]
Back to top


nismo
Tue Sep 16 2008, 01:18PM
 User Offline
Registered Member #9479
Joined: Thu Jul 31 2008, 09:03AM

Posts: 77
Thanked 1 time in 1 posts
How to retrieve a single element in one sector. i have got the data token sent by the sd card. But i can not get the data in it? What am i suppose to do? Below is my code

unsigned char readSector (void){
unsigned long i;
unsigned char buffer[SECTOR_SIZE];
L5:
sendBlock(); /*CMD17*/
clock(0xFF); /*8 clock cycle*/
clock(0xFF); /*8 clock cycle*/
if(response == 0x00){
L4:
clock(0xFF);
if(response == 0xFE){ /*0xFE is the data token*/
for(i=0;i<SECTOR_SIZE;i++){
buffer[i]=SPDAT; /*to store 512 byte data into buffer*/
}
clock(0xFF);
clock(0xFF);
}
else{
goto L4;/*if data token of 0xFE is not received go to L4*/
}
}
else{
goto L5;/*if the response 0x00 is not received go to L5*/
}
LCD_sendString("Processing"); /*If the card can get the data token 0xFE, the LCD will display 'Processint'*/
SD_cs = 1;
clock (0xFF);
return i;
}

void fileSystem (void){
unsigned char buffer[SECTOR_SIZE];
readSector(); /*Refer to the routine above*/
if(buffer[54] == 0x46) /*if the element in this array is 0x46, then it will print FAT16*/
LCD_sendString("FAT16");
}

i want to know whether array element 54 is 0x46 or not. If it is, the it is FAT 16... I find no problem with the code, but i still can not get what i want. Oh my, i already don't sleep for one day...

[ Edited Tue Sep 16 2008, 01:29PM ]
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