Step 2: Index Files on SD card

First you need to write a callback for the Filesystem to capture data on each file as it is read:

struct sPlaylist {
unsigned int CurrentFile;
unsigned int FileCount;
unsigned int FileIndex;
} Playlist;

char IndexWavFile(unsigned char Filename[],unsigned char Extension[])
if(Extension[0]==87 && Extension[1]==65 && Extension[2]==86)
return ThinFAT_Fail;
The code above recive the filename and extension of the file being opened.  it then checks the file extension if it is 'wav' you can check any file extension useing the following table as it's acsii encoded:

the callback returns a fail for all of the files as it's only meant to index files.  you can use this same callback for indexing folders too.

once you have made the callback for indexing these files you can then hand this callback to the filesystem to be run for each of the files or folders found in the current folder.  the end of file callback needs to be included even if it's not going to be used.

// Find a file
ThinFAT_FindFile((*IndexWavFile), (*EndWavFile));
// Find a folder
ThinFAT_FindFolder((*IndexFolders), (*EndWavFile));
<p>Could you give us a schematic of this project? Thanks :)</p>
hi! <br> <br>My compiler cannot find the declarions of USISRL and USICNT ... where can i find the file with those variables? <br> <br>Thx <br> <br>F&Atilde;&iexcl;vero
Hi! Thanks for making this instructable. <br> <br>I am wondering if you were able to get a read/write system working? Or perhaps just a write? <br> <br>Thanks in advance!
sorry, I could only handle read only - writing needs to at least store a whole block or you lose everything that was on that block. that makes it difficult to write to the file system without it screwing up all the other files.
Thanks for the information! =)
hey dude... i don't understand why all the wires.. can you tell me what are the funtionality? <br />and the FAT file system.. where i do that?? sorry, but i'm REALLY new in this.... i'm lost. <br />Hey, it's a great project that i want to reproduce... of course, if you let me jeje
basically the FAT16 file system is how regular SD cards, not SDHC are formatted. this allows you to with the right adaptor and power supply to the card to search for files and folders and then read from them. it dosen't support long file names. but you can make any kind of search function you feel like. <br /> <br />on your microcontoller you'll have pins that you can wire to different things and they all have names. this is just the lables for what they go to in this programmed example. you should look up how SPI works, it'll be a good start to understanding how this works. also SD cards have the same voltage tolerances (excluding micro) as the MSP430. <br /> <br />
Thanks for making this an instructable.<br>Helps people like me who are learning about the msp430 in their spare time.<br>Will be trying this very soon. Built my own sdcard holder yesterday after reading this.<br>Thanks again. :)
I'm glad I could help you

About This Instructable


9 favorites

More by siskinedge: Running FAT16 on the Ti Launchpad
Add instructable to: