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.

https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-ccbd14b092b9424b82720ee446387c91/Firmware.zip

Thanks & Regards,

Snehal 

  • Can anyone please help me on this?

  • I tried to debug more on this, Basically when I try to write into the file after the timer event, the QSPI returns busy. I can see " Cannot init because QSPI is busy" this line. Now why is it busy and how to solve this?

  • 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

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

    Best regards
    Torbjørn

1 2 3 4