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

Nordic SDK QSPI driver call

Hi all,

             We had implemented Nordic QSPI using "nrf_drv_qspi_write" and "nrf_drv_qspi_read" operation , however I am seeing for page to write in flash of 4096 bytes with 512 bytes of QSPI write size limitation its taking 8.6 milli sec , when many streams (sensor data at stretch to be written into system) streams are getting hanged when flash logging is enabled .

So, wanted to check basic operations "nrf_drv_qspi_write" and "nrf_drv_qspi_read" if it blocks other sensor operations to process data ? Is it blocking call? If so how do we configure into dma mode?

Please help

    1. "You'll have to put a SW state-machine on top of the driver in order to know what source triggered the EVENTS_READY signal."
      Monitor what function last called read/write/erase/custom instr and you know what the source of the NRFX_QSPI_EVENT_DONE  was.

    2. "Do we need to set handler based Interrupt for qspi?"
      What do you mean? as opposed to what? 
  • Hi ,

         Please check below code.

    void qspi_init_call_back(nrfx_qspi_evt_t event, void *p_context)
    {

      if (event == NRFX_QSPI_EVENT_DONE) {
            qSpiXferDone = true;
        }
    }
    uint32_t nand_flash_qspi_init(void)
    {
        uint32_t err_code = NAND_SUCCESS;
        nrf_drv_qspi_config_t config = QSPI_NAND_FLASH_CONFIG;
        err_code = nrf_drv_qspi_init(&config, qspi_init_call_back, NULL);
     
        if(NRFX_SUCCESS != err_code)
        {
            NRF_LOG_INFO("QSPI init error,err_code=%d",err_code);
            return err_code;
        }
        nrf_qspi_ifconfig0_set_page_size(1);
        return NRFX_SUCCESS;
    }
    and this is write API
        eNand_Result ret = NAND_SUCCESS;
        uint32_t flash_address;
        if((size == 0)||(size > 512))
        {
            return NAND_PARAM_ERROR;
        }
        if((size&0x03) != 0)
        {
            size = (int)(floor((size+3)/4))*4;
    #ifdef PRINTS_OUT
            NRF_LOG_INFO("Size calculated=%d",size);
    #endif
        }
        if((NULL == in_array)||((column&0x03) != 0))
        {
            return NAND_PARAM_ERROR;
        }
        flash_address = (column << 8);
        if(size >= 4)
        {
            if(NRFX_SUCCESS != nrf_drv_qspi_write(in_array+4,size-4,flash_address))
            {
                NRF_LOG_INFO("QSPI nrf driver error!");
                return NAND_NRF_DRIVER_ERROR; 
            }
        }  
        while(qSpiXferDone)// prev buffer writing is'nt over skip writing hold buffer to write in next iteration
        {
           MCU_HAL_Delay(1);
        }
  • Basically I am setting even transfer done flag when event ready occurs, and processed after write is over , will be waiting in spi to be completed for it to get set to true.

    I will add state machine to diff b/n read/write/erase . But could I check with the above> 

  • Hi,

           nrf_drv_qspi_init is failing with below mentioned call back; inside 

    init function 

    m_cb.interrupt_driven = false; is set to false ; so it crashes when assigned call back.

  • Can you please post an example of link to an example of how to use qspi call back ? I am seeing qspi_init is crashing when call back is assigned

Related