Hi . I am trying to store values from from an ADC pin to a local file for every few milliseconds on LPC 11U24 . I first tried running the instructions of opening a file , writing the value and closing inside a loop , it ran for some time and the controller hung. So I ran this test program
<<test program>>
- include "mbed.h"
Serial pc(USBTX, USBRX);
LocalFileSystem local("local");
AnalogIn Ain1(p20);
int count=0;
int main() {
while (1)
{
pc.printf("\rcount - %d \r\n",count);
FILE* File1 = fopen("/local/datfile.txt","a");
fputc(count, File1);
fclose(File1);
count++;
}
}
The program stopped after 141 loop.
When i kept the opening and closing statements outside the loop and only the writing part inside it kept going for a long time . Could somebody please explain why this is happening . Thank you
Hi . I am trying to store values from from an ADC pin to a local file for every few milliseconds on LPC 11U24 . I first tried running the instructions of opening a file , writing the value and closing inside a loop , it ran for some time and the controller hung. So I ran this test program
<<test program>>Serial pc(USBTX, USBRX);
LocalFileSystem local("local");
AnalogIn Ain1(p20);
int count=0;
int main() {
while (1) {
pc.printf("\rcount - %d \r\n",count);
FILE* File1 = fopen("/local/datfile.txt","a");
fputc(count, File1);
fclose(File1);
count++; } }
The program stopped after 141 loop. When i kept the opening and closing statements outside the loop and only the writing part inside it kept going for a long time . Could somebody please explain why this is happening . Thank you