How to write and read data from NOR Flash using QSPI ?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write and read data from NOR Flash using QSPI ?

165 Views
theats
Contributor II

Hello,

I am a newbie here.

I am trying to write and read data from NOR FLASH of IMX6UL using QSPI.

I have used the evkmcimx6ul driver example for QSPI to read and write the data.

But, I am not able to read the data, and that's where I am having a doubt whether I am writing the data properly or not.

Below is the read and write code snippet for reference.

I have not done any changes to the driver example. It is as it is given in QSPI driver example.

/*Function to read and write */
void enable_quad_mode(void)
{
uint32_t writeData[4] = {0x10804505, 0x10804505,0x15240080,0x46854570};
uint32_t readData[4] = {0, 0, 0, 0};

/* Start the program */
QSPI_SetIPCommandSize(EXAMPLE_QSPI, 16);

while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & kQSPI_Busy)
{
}
QSPI_SetIPCommandAddress(EXAMPLE_QSPI, FSL_FEATURE_QSPI_AMBA_BASE);

/* Clear Tx FIFO */
QSPI_ClearFifo(EXAMPLE_QSPI, kQSPI_TxFifo);

/* Write enable */
cmd_write_enable();

/* Write data into TX FIFO, needs to write at least 16 bytes of data */
QSPI_WriteBlocking(EXAMPLE_QSPI, writeData FSL_FEATURE_QSPI_TXFIFO_DEPTH);

/* Set seq id, write register */
QSPI_ExecuteIPCommand(EXAMPLE_QSPI, 20);

/* Wait until finished */
check_if_finished();


/*Read data */

QSPI_SetIPCommandSize(EXAMPLE_QSPI, 16);

QSPI_SetIPCommandAddress(EXAMPLE_QSPI, FSL_FEATURE_QSPI_AMBA_BASE);

/* Set seq id, read register */
QSPI_ExecuteIPCommand(EXAMPLE_QSPI, 0);

QSPI_ReadBlocking(EXAMPLE_QSPI, readData,FSL_FEATURE_QSPI_RXFIFO_DEPTH);

}

So, can anyone please help with writing and reading the written data back?

And also can anyone please provide any reference code for reading the data from NOR FLASH using QSPI.

Any help will be appreciable.

Thank you.

Labels (2)
0 Kudos
1 Reply

135 Views
jimmychan
NXP TechSupport
NXP TechSupport

In the Yocto BSP, there is imx-test package. (bitbake imx-test).

 

Then the source code can be found in the <build_dir>/tmp/work/aarch64-<chip>-poky-linux/imx-test/.

There is test/mxc_spi_test/mxc_spi_test1.c. You can take this for reference._

 

0 Kudos