This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Help Wanted: nRF52840 QSPI + FatFS to Winbond W25N01GV

Looking for help creating an example similar to the usbd_msc example that works with the W25N01GV. Currently using SDK 15.0. Would like to see this work with FatFS or possibly another alternative better suited for flash. Please inquire in direct message here. Thanks!

  • Have you looked at the FatFs documentaion?

    That describes how to adapt the FatFs code to any target - basically, there is only one target-dependent file ...

  • Alternatively, you can check out the QSPI example. 

    Be aware that there is a current consumption bug in the QSPI. It is not very important when you just want to test this, but be aware of this before finishing your application.

    It is the errata number 122 in this document.

    I would suggest you check out the SDK\examples\peripheral\qspi example, since it looks like the W25N01GV supports QSPI. 

    You can easily test this example if you have the nRF52840DK, which uses QSPI on the flash storage chip on the DK.

    If you want to change the pins that the QSPI uses, these are decided in sdk_config.h. Note that when they are defined as NRF_QSPI_PIN_NOT_CONNECTED, it will use the default pins that are defined in pca10056.h.

    Also note that you may experience some weird behavior if you have long cables/PCB traces, and the QSPI_CONFIG_FREQUENCY is very high.

    Best regards,

    Edvin

  • Hi, have you solved it? I have problems with this memory too

  • I've not, though I've some ideas on how I'm going to do it. Just haven't gotten to that task yet. 

  • Hello,

    At least in SDK15.2.0 the usbd_msc project uses QSPI. Although it only creates random files (random file names) instead of writing to the files, it is possible to use this project to write in the files as well.

    If you replace fatfs_file_create() with this function:

    static void fatfs_create_test_file(void)
    {
        FRESULT ff_result;
        FIL file;
        uint32_t file_size = 0;
    
        ff_result = f_open(&file, "my_file.txt", FA_READ);
        if (ff_result != FR_OK)
        {
            NRF_LOG_ERROR("my_file.txt Does not exist\r\n");
            NRF_LOG_INFO("Creating my_file.txt");
            ff_result = f_open(&file, "my_file.txt", FA_CREATE_ALWAYS | FA_WRITE);
            if (ff_result != FR_OK)
            {
                if(!m_usb_connected)
                    NRF_LOG_ERROR("Unable to open or create file: my_file.txt");
                NRF_LOG_FLUSH();
                return;
            }
        }
    
        ff_result = f_close(&file);
        if (ff_result != FR_OK)
        {
            NRF_LOG_ERROR("Unable to close file: %u \r\n", ff_result);
            NRF_LOG_FLUSH();
            return;
        }
    
        file_size = f_size(&file);
        NRF_LOG_INFO("my_file.txt create SUCCESSFUL; file size = %d\r\n", file_size);
    }

    To create a specific file, and then you can use a function similar to this to write data to the file:

    static void write()
    {
        int i = 0;
        char log_record[128] = {0};
        char log_record_r[128] = {0};
    
        FRESULT ff_result;
        FIL file;
        uint32_t fileSize;
    
        ff_result = f_open(&file, "my_file.txt", FA_OPEN_APPEND | FA_OPEN_ALWAYS | FA_WRITE | FA_READ);
        if (ff_result != FR_OK)
        {
            if(!m_usb_connected)
                NRF_LOG_INFO("Unable to open or create my_file.txt: %u", ff_result);
            NRF_LOG_FLUSH();
            return;
        }
    
    
        sprintf(log_record, "Helloworld!\r\n");
    
    
        FSIZE_t ptr = f_tell(&file);
    
        i = f_printf(&file, log_record);
    
        i = f_close(&file);
        if (i != 0)
        {
          NRF_LOG_INFO("f_close != 0, %d", i);
        }
    
        NRF_LOG_INFO("Wrote Data Record");
    }

    Best regards,

    Edvin

Related