I am testing the TinyFat program with an application I made using the CrossArm software from Rowley. I used my XP to format an SD card with three files specifying (FAT) format in xp.
The first two files are very short (less than 100 characters long) and read great. The third file is slightly over 512 bytes just to see if it gets the next sector o.k. Unfortunately it only reads in (correctly) the first 512 byte sector of this long record. Then it reads in nothing.
I tried to walk thru the program and in the section below it seems to jump from the second return from the bottom to the last return from the buttom hence it doesnt return the LD_WORD value but instead the 1.
static
WORD get_cluster (WORD clust) /* Cluster# to get the link information */
{
WORD wc, bc;
DWORD fatsect;
FATFS *fs = FatFs;
if ((clust >= 2) && (clust < fs->max_clust)) { /* Valid cluster# */
fatsect = fs->fatbase;
if (fs->fs_type == FS_FAT12) {
bc = clust * 3 / 2;
if (!move_window(fatsect + bc / 512)) return 1;
wc = fs->win[bc % 512]; bc++;
if (!move_window(fatsect + bc / 512)) return 1;
wc |= (WORD)fs->win[bc % 512] << 8;
return (clust & 1) ? (wc >> 4) : (wc & 0xFFF);
} else {
if (!move_window(fatsect + clust / 256)) return 1;
return LD_WORD(&(fs->win[(clust * 2) % 512]));
}
}
return 1; /* Return with 1 means function failed */
}
I could be way off but this is my best guess so far. I must confess I haven’t figured out how exactly this works.
I suspect my XP may have formatted something out there besides a FAT16 format but I can’t prove it.
Any ideas would be appreciated.
Regards to all;