Hi all ,
I have an issue with MFS on SD Card file writing. I have function in which I open file (fopen()), then write into it (write()) and close file (fclose()). In that function I have several local variables defined. MFS writting only works when I declare these variables as volatile, otherwise file is not created/writen and in some situations SD card file sistem become corrupted (Windows require formating). All these problems disapears when I declare variables as volatile. Why this is happen . Is this some bug in MFS functions and interrupt handling or I make mistake. ?
For better understanding here is the part of function which not works well because not all locals are volatile :
volatile MQX_FILE_PTR fd;
int i , j , k;
enum_id = 1;
fd = fopen("c:mrk.bin","a+");
/* write header */
bytes_written = write(fd,&write_data,data_length);
// do something with variables //
I'm not so familiar with MFS. But, could it be a buffer overflow issue? So could you try to limit the data_length inside the parameter_to_file() function to max. Bytes you are awaiting? I know such issues at 8 and 16 bit processors, where an 32 bit value can be illegal because of interrupted copy operation. Which processor do you use?