AnsweredAssumed Answered

STM32Cube FatFS USB disk Problem

Question asked by owen.j on Dec 7, 2015
Latest reply on Dec 7, 2015 by Clive One
Hi have a SRAM Disk working using FATFS and USB. I can read and write files to the disk from my processor (STM32f427zit)  but the files do not get updated in windows explorer on the PC. If if unplug the USB and then plug it back in I get to see all the log files i have created, but then no new ones get added and again I have to unplug it and plug it in again - I guess it so something simple but I can't find it


  if(FATFS_LinkDriver(&SRAMDISK_Driver, SRAMDISK_Path) == 0)
  {
    if(f_mount(&RAMDISKFatFs, (TCHAR const*)SRAMDISK_Path, 0) == FR_OK)
    {
      f_mkfs((TCHAR const*)SRAMDISK_Path, 0, 0);
    }    
  }    

  while(1)
  {


....
    sprintf(FileName,"LPD%d.csv",Cnt);
     if (f_open(&NewFile, FileName, FA_CREATE_ALWAYS | FA_WRITE) == FR_OK)
     {
       for (i=0; i<2000; i+=4)
        {    
             sprintf(DataStr,"%d,",(short)(DMACodecData[i+1]<<8)+DMACodecData[i]);
            err=f_write(&NewFile, DataStr, sizeof(DataStr), (void *)&byteswritten);
            if (err!=FR_OK)
          {
             sprintf(LcdBuffer, "Failed %d",err);
             WriteXYLcd(0,3,LcdBuffer);
         }
         if (byteswritten!=sizeof(DataStr))
         {
             sprintf(LcdBuffer, "full %d",byteswritten);
            WriteXYLcd(0,4,LcdBuffer);
         }
        }
        f_close(&NewFile);
     }    

.....

  }

Thanks for any Ideas.

Outcomes