FAT FS USB MSC not opening file after enabling timers.

Hi, 

 I am using USB MSC code from sdk examples with QSPI module on development kit. I am using sdk 17.1.0. My project includes capturing some pulses on a GPIO and then saving the data inside the file of flash chip. I am able to mount the file system as well as write some data inside it. After this I enable the timers and ppi configuration. Now when I try to write some data from the timer1 handler, I am no longer able to open the created file and append data into it. It gives me an error of "FR_NOT_READY". Can anyone please help me with this? 

After test_init() function is called the timers and ppi start and I am no longer able to open the file and write into it from the timer1 event handler. What could be causing this?

Please check the attached project. It is the same as USB MSC code from SDK example. Only added ppi and timers. This project can be ran on NRF52840 development kit.

Thanks & Regards,

Snehal 

Parents
  • Hi 

    For some reason I can't open the attachment. Would you be able to try uploading it again? 

    A general comment though, if you are trying to write to the external flash directly from an interrupt it could be problematic. Would you be able to try to set a flag or similar in the interrupt, but run the actual write operation from main()? 

    Alternatively you can use the app_scheduler module to schedule an activity to be run in main/thread context. 

    Best regards
    Torbjørn

  • Hi Torbjørn , Please check I have uploaded the firmware again here, 

    6303.Firmware.zip

    Would you be able to try to set a flag or similar in the interrupt, but run the actual write operation from main()? 

    >> Yes I tried this. I set a flag into "timer1_event_handler". I checked the flag in main function while loop just as shown below but it did not work.

    while (true)
    {

           while (app_usbd_event_queue_process())
           {
                 if(flag == 1)
                 {
                      write_data_in_file(23,23);
                      get_memory_space(&total,&free1);

                     flag =0;
                  }
           }
             NRF_LOG_FLUSH();
    }

    Thanks & Regards,

    Snehal.

  • Hi Snehal

    The QSPI supports so called custom instructions, which allow you to send and receive up to 8 bytes in a way similar to SPI, but I think the best option in this case is to disable the QSPI interface completely and enable one of the SPIM interfaces on the same bus, but with a different chip select line. 

    You can not do this when the USB driver is connected to the flash, since it will require exclusive access to the QSPI interface as I mentioned earlier, but when you are only accessing the flash locally from the nRF52840 it should be possible to disable the QSPI, enable the SPIM, access the MAX sensor, disable SPIM, re-enable QSPI, and then be able to access the flash again. 

    You do have to make sure that any ongoing flash operations are completed by the time you make this change. 

    Best regards
    Torbjørn

  • Okay. I will try implementing this. Thanks for your suggestion.

    Regards,

    Snehal

  • Good luck Slight smile

    If you ever do a redesign of the hardware I would strongly recommend splitting this up. You will lose 3 GPIO's, but will be able to simplify the code significantly, and won't have any throughput implications because you have to share the bus. 

    Best regards
    Torbjørn

  • Hi Torbjorn,

                 I will consider your suggestion. One more thing I wanted to ask. With the USB MSC drivers I am able to create a xcel file. The format of file is "TEST.XLS". Now this file is detected as Microsoft Excel 97-2003 worksheet on my laptop. Even if I change the format to "TEST.XLSX" it is still detected in XLS format 97-2003 worksheet. Is there any way we can change the format to be detected as TEST.XLSX??

    Thanks & Regards,

    Snehal

  • Hi Snehal

    I am guessing this is caused by the file name limit of FAT, which limits you to a file name length of 8 characters and an extension length of 3 characters. 

    More information here.

    To check if this is the problem, could you try to rename the file to use a longer name and see what happens? 

    Try "testtesttest.xls" for instance. 

    Best regards
    Torbjørn 

Reply Children
No Data
Related