AnsweredAssumed Answered

read/write multiple files using fatfs

Question asked by khan.umair on Mar 14, 2015
Latest reply on Mar 14, 2015 by francescato.diego
i require to open multiple files simultaneously and, read and write multiple files using stm32f4 and fatFs , as a test i used f_open with 4 different file names and file pointers but only two files got created in card at the end, and one contains data why fatfs never creates multiple files if we use f_open with different FIL pointers and different names??


as a reference following was test code

               f_mount(0, &filesystem);


               f_open(&file,  "DATA.YUV", FA_READ | FA_WRITE | FA_CREATE_ALWAYS);
               f_open(&file2, "DATA2.YUV", FA_READ | FA_WRITE | FA_CREATE_ALWAYS);
               f_open(&file3, "DATA2.YUV", FA_READ | FA_WRITE | FA_CREATE_ALWAYS);
               f_open(&file4, "DATA2.YUV", FA_READ | FA_WRITE | FA_CREATE_ALWAYS);
          
          
               f_write(&file, &buffer[0] , size*4, &bw);
               if (bw<(size*4)) while(1);               


               f_write(&file2, &buffer[0] , size*4, &bw);
               if (bw<(size*4)) while(1);


               f_write(&file3, &buffer[0] , size*4, &bw);
               if (bw<(size*4)) while(1);


               f_write(&file4, &buffer[0] , size*4, &bw);
               if (bw<(size*4)) while(1);               
          
               f_close(&file);
               f_close(&file2);
               f_close(&file3);
               f_close(&file4);
               
               if (f_mount(0, NULL) != FR_OK) {
               printf("could not close filesystem \n\r");
               }

Outcomes