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

Reply
  • 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

Children
  • 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

    You shouldn't add this code inside the while (app_usbd_event_queue_process()) loop, it should be outside. Something like this: 

    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();
    }

    Best regards
    Torbjørn

  • Thanks for your help. One question I wanted to ask. When the USB is connected the device is not able to save data inside the flash. If I remove USB from laptop only then device can save data inside the file. Can we save data inside the file even when USB is connected?

    Regards,
    Snehal

  • Hi Snehal

    The USB MSC class does not permit sharing of the storage medium between multiple users. It assumes and requires exclusive access to the underlying flash hardware. 

    You can disable the USB stack completely in the code in order to be able to access the flash, but this will probably not provide for a very good user experience since it will make it look like the USB device is disconnected on the host (PC) side as well. 

    Best regards
    Torbjørn

  • Hi Torbjørn,

             Thank you so much for your reply. Now that this file is created and stored inside the flash chip. Is there any way the nrf52840 can send this file via ble to the mobile APP. Is it even possible?

    Thanks & Regards,

    Snehal

Related