what does it mean if the QSPI.open function returns value 6?

err = g_qspi0.p_api->open(g_qspi0.p_ctrl, g_qspi0.p_cfg);
if (SSP_SUCCESS != err)   // here err is 6
{
while(1);
}

  • Which version of the SSP are you using and on which device?

    SSP error code 6 corresponds to SSP_ERR_UNSUPPORTED. This could mean that the feature of the QSPI driver you are trying to use is not available or perhaps the QSPI peripheral itself is not available.

    Ian.

  • In reply to Ian:

    if you are using the S7-DK board, enusre that the QSPI DIP switch is set to ON (S5 on the top board, switch no. 2)

  • In reply to Jeremy:

    I changed the qspi chip. now,  open is ok, but erase and pageprogram is not functioning. ther all return 0, which is success, but the qspi memory is not erased or re-written. is it because of xip interface?

  • In reply to marinayelken:

    Hello Erkut,

    Once you open your QSPI driver, "Memory" tab will no longer show valid contents of QSPI (this is because debugger reads it through the CPU and opening the driver takes QSPI out of ROM access mode, hence this interface is no longer functional). Once you close the QSPI driver you should be able to verify the QSPI contents. Alternatively, use QSPI read function to verify if the data was written successfully.

    Regards

  • In reply to Karol:

    the sequence I follow is, open, erase, write, close. after it there is a breakpoint, and I copy the contents to a string with strcpy(dest,src); the contents of "char dest[32]" is not what I wrote to that address. they are old values, before I erase the flash.

  • In reply to marinayelken:

    after all function calls, I check the return value and the return value is success (zero)

  • In reply to marinayelken:

    Are you using statusGet to see whether write/erase is still active? Here's a snippet I use to erase the first 4MB of the QSPI:

    for (uint32_t i = 0; i < (QSPI_SIZE / QSPI_SECTOR); i++)
    {
        status = g_qspi.p_api->sectorErase(g_qspi.p_ctrl, QSPI_BASE + (i * QSPI_SECTOR));
        if (status)
            __BKPT(0);

        bool not_ready = true;

        while (not_ready)
        {
            status = g_qspi.p_api->statusGet(g_qspi.p_ctrl, &not_ready);
            if (status)
                __BKPT(0);
        }
    }

    Regards

  • In reply to Karol:

    {

    ssp_err_t err;

    bool qspi_we_active; 

    uint32_t i;

    err = QSPI.p_api->open(QSPI.p_ctrl, QSPI.p_cfg);

    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    /* Select Bank Zero */
    err = QSPI.p_api->bankSelect(0);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    for (i = 0; i < 1; i++)
    {
    err = QSPI.p_api->sectorErase(QSPI.p_ctrl, (uint8_t *)(0x60000000 ));
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    /* Wait for the erase operation to complete */
    do{
    err = QSPI.p_api->statusGet(QSPI.p_ctrl, &qspi_we_active);
    if(SSP_SUCCESS != err)
    {
    while(1);
    }
    } while (true == qspi_we_active);
    }


    char devtext[32];

    strcpy(devtext, "loop 01 - device 001");

    err = QSPI.p_api->pageProgram(QSPI.p_ctrl, 0x60000000, &devtext[0], 32);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    strcpy(devtext, "loop 01 - device 002");

    err = QSPI.p_api->pageProgram(QSPI.p_ctrl, 0x60000020, &devtext[0], 32);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }

    err = QSPI.p_api->close(QSPI.p_ctrl);
    if (SSP_SUCCESS != err)
    {
    while(1);
    }
    // breakpoint is at the line below. I step and check the value,
    strcpy(devtext, &devicesTEXT[0][0][0]);
    strcpy(devtext, &devicesTEXT[0][1][0]);
    }

  • In reply to marinayelken:

    erase also is not functioning. I assign values to that adresses in initialization section.  I still have that values after the last line, the strcpy copies that values (assigned at the initialization time) to the devtext char array

  • In reply to marinayelken:

    Hello Erkut,

    Try adding the status-checking loop after each write you perform. Processor returns from the function faster than QSPI can execute the write command.

    Regards

  • In reply to Karol:

    also sector erase is not functioning :-(. it is just after open, bankselect,  and there is status checking after it.

  • In reply to marinayelken:

    after adding status checking loop after pageprograms, the sector erase is also worked !

  • In reply to marinayelken:

    /*******************************************************************************************************************//**

    * @brief  Select the bank to access.

    *

    * A bank is a 64MB sliding access window into the flash memory space. This function sets the current bank.

    *

    * @retval SSP_SUCCESS             Bank successfully selected.

    *

    **********************************************************************************************************************/

    ssp_err_t R_QSPI_BankSelect (uint32_t bank)

    {

       /* Return back to ROM access mode */

       HW_QSPI_BANK_SELECT(bank);

       return SSP_SUCCESS;

    }

    Is this function needed after each "->open" ? or if the default value is not changed, should I use it once?

    The function only assigns the value of R_QSPI->SFMCNT1_b.QSPI_EXT. see in the lines below :

    /*******************************************************************************************************************//**

    * Set the BANK Switching Address

    **********************************************************************************************************************/

    __STATIC_INLINE void HW_QSPI_BANK_SELECT (uint32_t bank)

    {

       R_QSPI->SFMCNT1_b.QSPI_EXT = (uint8_t)(0x3F & bank);

    }

  • In reply to marinayelken:

    this field is not referenced in any other files, so I am not sure that function is doing something, perhaps it is reserved for some other chip, or version of ssp. ??

  • In reply to marinayelken:

    The QSPI_EXT bits of the register SFMCNT are used as the upper 6 bit of the address used to access the External QSPI device space:-

    See section 39.3 of the S7G2 HW manual for more information