This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

use ncs1.5.0 fats and nrf5340 ,fil can not save in sd card

i use a thread to save fil like below ,and find can not save file in sd card ,sd card SPI test ok . before enter in loop. close fil and reset system can save fil in sd card 

but when code run in thread loop , want to open fil to write ,and close fil to save in sd card . fil can not save .i do not kown where to open /close fil to save and re-write

for (;;) {


  if(k_sem_take(&test_sem, K_MSEC(5)) == 0)
 {

    g_sd_ecg_temBuf->u32TotalLen+=21;
    f_lseek(&fil , g_sd_ecg_temBuf->u32TotalLen);

     f_write(&fil ,"total line:0000000000", 21,&bw);

  }
  //every (300*100 ms = 30 second)save file in sd card
  if(k_sem_take(&auto_save_file_sem, K_MSEC(30)) == 0)
  {
    f_close(&fil);//save file
   //re_open corrent file for next writing
   f_open(&fil, (const char*)"0:/zhfdata.txt", FA_WRITE | FA_CREATE_ALWAYS);

  }

}

Parents Reply Children
No Data
Related