AnsweredAssumed Answered

QSPI flash erase/write does not work after reading out flash memory

Question asked by normanmueller on Jul 12, 2016
Latest reply on Aug 4, 2016 by Iva Dorazinova

I use the FRDM-K82F board and try to write to the external NOR-flash via QSPI interface. For the first test I used the driver demo "qspi_polling_transfer". This works fine if I do not modify it, but if I put in code that reads out flash memory via AHB before writeing to it, reprogramming the flash memory does not work anymore. I have no clue why?

 

Here is the code example:

 

void qspi_polling(void)

{

    uint32_t i = 0;

    uint32_t err = 0;

 

    //####### if this code is inserted, erase and program_page does not work #######

    for (i = 0; i < 64; i++)

    {

        PRINTF("The flash value in %d is %x\r\n", i, ((uint32_t *)(FSL_FEATURE_QSPI_AMBA_BASE))[i]);

    }

    //##############################################################################

   

   

    erase_sector(FSL_FEATURE_QSPI_AMBA_BASE);

    PRINTF("Erase finished!\r\n");

 

    /* Program a page */

    program_page(FSL_FEATURE_QSPI_AMBA_BASE, buff);

    PRINTF("Program data finished!\r\n");

 

    for (i = 0; i < 64; i++)

    {

        if (((uint32_t *)(FSL_FEATURE_QSPI_AMBA_BASE))[i] != buff[i])

        {

            PRINTF("The data in %d is wrong!!\r\n", i);

            PRINTF("The flash value in %d is %d\r\n", i, ((uint32_t *)(FSL_FEATURE_QSPI_AMBA_BASE))[i]);

            err++;

        } else {

            PRINTF("The flash value ok in %d is %x\r\n", i, ((uint32_t *)(FSL_FEATURE_QSPI_AMBA_BASE))[i]);

        }

    }

    if (err == 0)

    {

        PRINTF("Program through QSPI polling succeed!\r\n");

    }

}

Outcomes