AnsweredAssumed Answered

Using QSPI flash A1 for XIP and QSPI flash B1 for data storage

Question asked by THIVYA ASHOK KUMAR on Jul 9, 2020
Latest reply on Jul 14, 2020 by jeremyzhou

I came across a few posts for using 2 QSPI devices like Can we use a XIP flash and a data flash at the same FlexSPI controller? 

One of the replies mentioned XIP uses AHB while programming the flash uses IP. 

1. Here is my flexspi_nor_flash_init()

 

flexspi_device_config_t codedeviceconfig = {
.flexspiRootClk = 120000000,
.flashSize = 0x2000,
.CSIntervalUnit = kFLEXSPI_CsIntervalUnit1SckCycle,
.CSInterval = 2,
.CSHoldTime = 3,
.CSSetupTime = 3,
.dataValidTime = 0,
.columnspace = 0,
.enableWordAddress = 0,
.AWRSeqIndex = 0,
.AWRSeqNumber = 0,
.ARDSeqIndex = NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD,
.ARDSeqNumber = 1,
.AHBWriteWaitUnit = kFLEXSPI_AhbWriteWaitUnit2AhbCycle,
.AHBWriteWaitInterval = 0,
};
flexspi_device_config_t datadeviceconfig = {
.flexspiRootClk = 120000000,
.flashSize = 0x800,
.CSIntervalUnit = kFLEXSPI_CsIntervalUnit1SckCycle,
.CSInterval = 2,
.CSHoldTime = 3,
.CSSetupTime = 3,
.dataValidTime = 0,
.columnspace = 0,
.enableWordAddress = 0,
.AWRSeqIndex = 0,
.AWRSeqNumber = 0,
.ARDSeqIndex = NOR_CMD_LUT_SEQ_IDX_READ_FAST_QUAD,
.ARDSeqNumber = 1,
.AHBWriteWaitUnit = kFLEXSPI_AhbWriteWaitUnit2AhbCycle,
.AHBWriteWaitInterval = 0,
};

void flexspi_nor_flash_init(FLEXSPI_Type *base)
{
flexspi_config_t config;

flexspi_clock_init();

/*Get FLEXSPI default settings and configure the flexspi. */
FLEXSPI_GetDefaultConfig(&config);

/*Set AHB buffer size for reading data through AHB bus. */
config.ahbConfig.enableAHBPrefetch = true;
config.ahbConfig.enableAHBBufferable = true;
config.ahbConfig.enableReadAddressOpt = true;
config.ahbConfig.enableAHBCachable = true;
config.rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackFromDqsPad;
FLEXSPI_Init(base, &config);
// FLEXSPI_EnableAHBParallelMode(EXAMPLE_FLEXSPI,true);

/* Configure flash settings according to serial flash feature. */
FLEXSPI_SetFlashConfig(base, &codedeviceconfig, kFLEXSPI_PortA1);
FLEXSPI_SetFlashConfig(base, &datadeviceconfig, kFLEXSPI_PortB1);

/* Update LUT table. */
FLEXSPI_UpdateLUT(base, 0, customLUT, CUSTOM_LUT_LENGTH);

/* Do software reset. */
FLEXSPI_SoftwareReset(base);
}

 

1. FLEXSPI_SetFlashConfig(base, &datadeviceconfig, kFLEXSPI_PortB1);

When the above line of code is executed, a hex value is filled in the 2MB chip instead of the being set to 0xFF. Also, when I try to access the 2nd memory, I can't erase it or write to it. Reading using memcpy() gives weird values. From the RM, I understood that the address of the second flash would start at 0x60000000 + Flash1's size. 

 

2. I have all the flexspi code pulled into the RAM for execution and the interrupts are disabled before accessing the flash because I had to do that while I was using a single flash earlier for XIP and also for data storage. Could this be a problem?

3.  FLEXSPI_EnableAHBParallelMode(EXAMPLE_FLEXSPI,true);

Using this line of code causes the application to be stuck in a loop and does not recover. I believe that I need not use AHB in parallel mode since I'm using XIP only on Flash A1 but I should use IP in parallel. Is that correct?

4. I use kFLEXSPI_PortB1 while trying to access the second flash with the address calculated as above. But, no luck.

 

What am I doing wrong? Am I missing initialization steps?

Outcomes