When I traverse the root directory like this:
Code: Select all
while ( 1 ) // Main loop: forever
{
restart:
while(Mmc_Card_Detect) // Loop until card is detected, pin reversed
;
if (FAT32_init() != 0) // Now using FAT32 library to init the card
{
show_error_lights(LIGHTS_CODE_FAT_NOT_INIT);
goto restart;
}
first_flag = 1;
for ( file_count = 0; file_count < MAX_FILES_FROM_DIR; ) // For every directory entry
{
if ( first_flag == 1 )
{
first_flag = 0;
ret_code = FAT32_FindFirst(&dirent);
if ( ret_code != FOUND ) // We only want to run this once per directory scan
{
count_out_FAT_error_integer(ret_code);
goto restart;
}
}
sprintf(debug_buf, "a file %d r equals %d a equals %d", file_count, ret_code, dirent.Attrib);
debug_say(debug_buf);
}
else
{
dirent.Attrib = 66;
dirent.NameExt[0] = 0;
ret_code = FAT32_FindNext(&dirent);
if ( ret_code != FOUND )
break; // This means "end of dir, rewind
sprintf(debug_buf, "a file %d r equals %d a equals %d", file_count, ret_code, dirent.Attrib);
debug_say(debug_buf);
}
// Store audio file names in MAX_... sized array here
}
// Other code to loop through and play audio based on file names here
// Rest of program here etc.
Problem: I get one file on FindFirst, and then the 2nd file on FindNext, and then the same second file forever until I hit the MAX of the loop. Note that I "scribble" on the dirent variable to make sure I'm not crazy...and each time its filled with good data (from the same file again). Second filename is "blue.mp3" and attribute ("r") is 32....ARCHIVE.
1) I am thinking that my audio debugger is triggering the problem the regular play code does
2) Tomorrow I'm going to try (painfully) with my "lights only debugger" that can flash out both integers and arbitrary ASCII and see if the audio debugger statements are triggering this bug even though
3) I saw some other posts about SPI1 and FAT32. I don't get it: if both key devices are ON SPI1, how can I do anything about without a hardware change?
Thanks much in advance!
(the experienced guy made humbly into a brand-new n0ob) G.