AnsweredAssumed Answered

FlexSpi NOR and NAND Flash Configuration

Question asked by Patrick Belohlavek on Jun 10, 2020
Latest reply on Jun 17, 2020 by Sabina Bruce

Hello,

 

we are using a NOR flash on Port A1 and a NAND flash on Port B1. This configuration works when the project is downloaded via LPC-Link2 debugger. Our problem occurs without the debugger after power on. The FLEXSPI_TransferBlocking function doesn't exchange any data with the NAND flash. There is no clock and no chip select during FLEXSPI_TransferBlocking function call.

 

Why does the communication with the NAND flash works druing debugging and why does it fails after power on?

 

The MCUXpresso IDE is used for this project.

 

- flash configuration:

 

flexspi_device_config_t NORFlashConfig = {
    .flexspiRootClk = 96000000,
    .flashSize = NOR_FLASH_SIZE,
    .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 NANDFlashConfig = {
    .flexspiRootClk     = 96000000,
    .isSck2Enabled         = false,
    .flashSize             = NAND_FLASH_SIZE,
    .CSIntervalUnit     = kFLEXSPI_CsIntervalUnit1SckCycle,
    .CSInterval         = 2,
    .CSHoldTime         = 3,
    .CSSetupTime         = 3,
    .columnspace         = 0,
    .enableWordAddress     = false,
    .dataValidTime         = 0,
    .AWRSeqIndex         = 0,
    .AWRSeqNumber         = 0,
    .ARDSeqIndex         = 0,
    .ARDSeqNumber         = 0,
    .AHBWriteWaitUnit     = kFLEXSPI_AhbWriteWaitUnit2AhbCycle,
    .AHBWriteWaitInterval = 0,
    .enableWriteMask     = false,
};

 

- clock settings:

 

    CLOCK_InitUsb1Pll(&g_ccmConfigUsbPll);
    CLOCK_InitUsb1Pfd(kCLOCK_Pfd0, 30);   /* Set PLL3 PFD0 clock 288MHZ. */
    CLOCK_SetMux(kCLOCK_FlexspiMux, 0x3); /* Choose PLL3 PFD0 clock as flexspi source clock. */
    CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2);   /* kCLOCK_Pfd0, 30 -> flexspi clock 96M. */

 

- FLEXSPI settings and configuration:

 

void flexspi_set_config(flexspi_config_t *config)
{
    memset(config, 0, sizeof(*config));

 

//    config->rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackInternally;
    config->enableSckFreeRunning = false;
    config->enableCombination = false;
//    config->enableDoze = true;
    config->enableHalfSpeedAccess = false;
    config->enableSckBDiffOpt = false;
    config->enableSameConfigForAll = false;
    config->seqTimeoutCycle = 0xFFFFU;
    config->ipGrantTimeoutCycle = 0xFFU;
//    config->txWatermark = 8;
//    config->rxWatermark = 8;
    config->ahbConfig.enableAHBWriteIpTxFifo = false;
    config->ahbConfig.enableAHBWriteIpRxFifo = false;
    config->ahbConfig.ahbGrantTimeoutCycle = 0xFFU;
    config->ahbConfig.ahbBusTimeoutCycle = 0xFFFFU;
    config->ahbConfig.resumeWaitCycle = 0x20U;
    memset(config->ahbConfig.buffer, 0, sizeof(config->ahbConfig.buffer));
    for (uint8_t i = 0; i < FSL_FEATURE_FLEXSPI_AHB_BUFFER_COUNT; i++)
    {
        config->ahbConfig.buffer[i].bufferSize = 256; /* Default buffer size 256 bytes*/
    }
    config->ahbConfig.enableClearAHBBufferOpt = false;
//    config->ahbConfig.enableReadAddressOpt = false;
//    config->ahbConfig.enableAHBPrefetch = false;
    config->ahbConfig.enableAHBBufferable = false;
    config->ahbConfig.enableAHBCachable = false;

 


    config->enableDoze = false;
    config->ahbConfig.enableClearAHBBufferOpt     = true;
    config->ahbConfig.enableAHBPrefetch         = true;
    config->rxSampleClock = kFLEXSPI_ReadSampleClkLoopbackFromDqsPad;
    config->txWatermark = 128;
    config->rxWatermark = 128;
}

 

void flexspi_flash_init(FLEXSPI_Type *base)
{
    flexspi_config_t config;
    
    int_Disable();

 

    flexspi_flash_clock_init();

 

    flexspi_set_config(&config);
    FLEXSPI_Init(FLEXSPI, &config);

 

    FLEXSPI_SetFlashConfig(FLEXSPI, &NORFlashConfig, kFLEXSPI_PortA1);    
    FLEXSPI_SetFlashConfig(FLEXSPI, &NANDFlashConfig, kFLEXSPI_PortB1);

 

    FLEXSPI_Enable(FLEXSPI, true);

 

    FLEXSPI_UpdateLUT(base, 0, customLUT, sizeof(customLUT)/4);

 

    FLEXSPI_SoftwareReset(FLEXSPI);

 

    int_Enable();

 

    flexspi_nand_flash_wait_bus_busy(); // <- function can not read status register from NAND flash after power on
}

Outcomes