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

    When using the SoftDevice the initialization sequence can be important. There aren't a lot of examples showing USB and BLE, but there are some, including the usbd_ble_uart example in the peripherals folder. 

    Could you take a look at that example and try to initialize your modules in the same order?

    Also, did you make sure to add all the project defines needed to use BLE and the SoftDevice?

    Best regards
    Torbjørn

  • I have solved the issue. The SDH events need to be in interrupt mode and not in polling mode. Setting that to interrupt mode solved my issue.

    I had one more doubt. On the same SPI lines I have one more chip MAX3421E which is SPI based. Is it possible that QSPI chip and SPI chip will work properly?

  • Hi Snehal

    I think it will be quite complex to make the flash driver and the sensor driver share the QSPI interface in a good way, even if the QSPI interface can be used to access SPI devices. 

    There are 4 dedicated SPI modules in the nRF52840, can't you use one of those instead to interface the MAX3421?

    Did you already use all the pins on the device? 

    Best regards
    Torbjørn

  • Hi Torbjorn,

    Actually the hardware is already built and both chips are on same SPI lines. Can we manage them somehow using Chip select pin?

    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

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

Children
Related