sebmadgwick wrote:After a few hours I have given up on getting CRC working. I don't think that a 3.7MHz SPI bus on a processional PCB with tracks <30mm in length is resulting in bit errors. This is supported by the fact that I have written many >100MB files with no content errors.
UhClem, thanks for that tip but I do not think it would be an productive exercise for me. I do not have a great understanding of FAT. The FAT library I am using is straight out of a book as I am extremely limited in how much time I can spend on this work.
You could perform a simple test even without understanding FAT16. Build a large test file system and then write a large file to it using your FAT16 code. Large enough so that when writing to a SD card you have trouble. Then check the file to see if it is mangled. If it is, then the problem is with the FAT16 code and not the cards.
Do you have any suggestions as to where my system could be going wrong, given: I can write 100MB and 200MB files with no FAT errors or file content errors, but when I created that 500MB file, all files on the drive become corrupt. It may or may not be relevant that larger files are created over a far longer period of time.
It has been a year or so since I was deep into the FAT code so I have forgotten most of the details. But a problem that appears only with large files suggests an overflow of some sort. Since it doesn't fall on an obvious boundary for 16 or 32 bit numbers, it would be subtle. Something like overflowing an intermediate operation. Not that I can think of a reason for that at the moment.
What FAT library are you using?