Hi,
someone who has worked on SD cards can help me out here. I just completed my FAT32 routines for microSD card. I've got little problem with calculating the free memory of the card. When I check on my PC, windowsXP shows free memory as 806.240256 MB but my function is showing 806.395904 MB.
What I'm ding here is counting all the clusters marked as free clusters starting from the root cluster and then multiplying with sectorPerCluster and bytesPerSector. The difference is exactly equal to 36 cluster memory.
I thought may be windows is removing bad clusters, so i put a check for bad clusters also and subtracted it from total free cluster count, but the result is same (the program is not able to find any bad cluster, may be since the card is new).
And since i'm counting from root cluster only, the reserved clusters are already removed from the calculation.
I just re-formatted the card and checked with windows (no files stored): total memory is 1013.809152 MB, free memory=1013.805056 MB and with my code, total memory is same as windows' but free memory is 1013.960704 MB. Still exactly 38 clusters!
The card free memory is becoming greater than the total memory. certainly, something is wrong with my code only, not with windows!
Problem solved yesterday!
I was counting 2 reserved entries in the first FAT sector and 36 extra entries in tha last sector (i was counting till the end of the last FAT sector, whereas I was supposed to count only till the entry related to the last data cluster).