Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
I am trying to build a logger, this is a first trial with SD card. I can't figure out what is wrong with this very simple code. When I comment the loop, it writes one line to a card without problem. If I use the for loop, the file is created but stays empty; I have the same problem with USB memory. However it works on local file system.
Any idea?
#include "mbed.h" #include "string" #include "SDHCFileSystem.h" //LocalFileSystem fs("sd"); SDFileSystem sd(p5, p6, p7, p8, "sd"); // mosi, miso, sclk, cs int main() { FILE *fp = fopen("/sd/my2file.txt", "w"); for(int i = 0; i < 1000; i++){ fprintf(fp, "Hello World! \n"); wait(0.1); } fclose(fp); }