Issue with SPI SD card, System can write files just 12 times

23 Feb 2017

Hi everybody, After hours and hours of developing an application based on mbed platform, I got a horror problem with SD card. When I was testing, I found that while logging some measured data in files everything goes well until the 13th file is created, and weirdly after I fopen the 13th file as writing (surely I won't forget fclose!) whole FAT and local file system won't work. (and remains not working)

here is the code: (inside main loop) for (int i = 0; i < 20; i++) { sprintf(temp, "/sd/%d.txt", i); my_debug.printl(i); my_debug.printl(","); my_debug.println( (int) LLD_FAT_writeFile(temp, "this is data!")); }

LLD_FAT_writeFile(const char * adr, const char * data) is a function that writes the data inside the given address and checks if the new file is made. (just checks the existence of the file) here is the definition of this function: bool LLD_FAT_writeFile(const char * adr, const char * data) { FILE *fpnew = fopen(adr, "w"); int lenn = strlen(data); for (int i = 0; i < lenn; i++) fputc( (int) data[i], fpnew ); fclose(fpnew);

fpnew = fopen(adr, "r"); if(fpnew == NULL) return false; else return true; }

when I run the code on micro, I get this: 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 10,1 11,1 12,1 13,0 14,0 15,0 16,0 17,0 18,0 19,0 20,0

Reveals that from the 13th file the problem occurs and remains.

23 May 2018

You need to close the file after fpnew = fopen(adr, "r"); if(fpnew == NULL) return false; else return true; }

20 Mar 2019

The following part where it will be able to manage it in such a https://netgears.support/blog/netgear-r6700-nighthawk-ac1750-review/ the part where the user will find out the work for which it will be getting the overall work which may be going to manage it.