We have a custom board where we can't use the DQS pad for flexspi port A, and thus we can only run flash at a max speed of 60 MHz.
In the nor polling SDK example, I made the following changes in system_MIMX1024.c (called from startup code) to accommodate for the 60 MHz requirement.
/* Configure FLEXSPI_A_DQS */
// CHANGE #1: Disabled, we don't have DQS pad available
// IOMUXC -> SW_MUX_CTL_PAD[86] = IOMUXC_SW_MUX_CTL_PAD_MUX_MODE(1) | IOMUXC_SW_MUX_CTL_PAD_SION(1);
/* Disable I cache */
if (SCB_CCR_IC_Msk == (SCB_CCR_IC_Msk & SCB->CCR))
{
SCB_DisableICache();
}
/* Re-Configure FLEXSPI NOR via ROM API, for details please refer to the init function of ROM FLEXSPI NOR flash
driver which is in fsl_romapi.h and fsl_romapi.c in the devices\${soc}\drivers directory of SDK package */
uint8_t flexspi_nor_config[512];
memcpy((void *)flexspi_nor_config, (void *)FLASH_CONFIG_ADDRESS, sizeof(flexspi_nor_config));
//flexspi_nor_config[12] = 1U; /* kFLEXSPIReadSampleClk_LoopbackFromDqsPad */
//flexspi_nor_config[70] = 7U; /* kFLEXSPISerialClk_133MHz */
flexspi_nor_config[12] = 0U; /* CHANGE #2: kFLEXSPIReadSampleClk_LoopbackInternally */
flexspi_nor_config[70] = 3U; /* CHANGE #3: kFLEXSPISerialClk_60MHz */
flexspi_nor_init_t flash_init = (flexspi_nor_init_t)ROM_FLASH_INIT_ADDRESS;
flash_init(0U, flexspi_nor_config);
But, I also see that this SDK example configures the FlexSPI clock (app.h, flexspi_clock_init):
/* Switch to PLL2 for XIP to avoid hardfault during re-initialize clock. */
CLOCK_InitSysPfd(kCLOCK_Pfd2, 24); /* Set PLL2 PFD2 clock 396MHZ. */
CLOCK_SetMux(kCLOCK_FlexspiMux, 0x2); /* Choose PLL2 PFD2 clock as flexspi source clock. */
CLOCK_SetDiv(kCLOCK_FlexspiDiv, 2); /* flexspi clock 133M. */
Can I leave the FlexSPI clock running at 133 MHz when flash is supposed to run at 60 MHz?
Or do I need to reconfigure clocks to get a FlexSPI clock frequency that is exactly 60 MHz?
Does the FlexSPI clock frequency need to correspond with the configured flash speed?
Hi @bp1979 ,
Please check the content from the RT1024, you will get the answer:
ROM didnt use the DQS, so the FCB limit to the 60Mhz.
But in the code, if you enable the DQS, then you change to more than 60Mhz, it's OK to use.
Best Regards,
Kerry
The question is not how I can get a faster flash speed. The question is what is the relation between the FlexSPI clock and the frequency that flash is running at.
I have done some testing, and it seems to work in either case. When I set FlexSPI clock to 133 MHz, or when I comment out the code completely (leaving the FlexSPI in default state set by ROM?)
Also when I try different values for the divider, flash on port A and port B seem to work just fine.
So how does the flash device know on which frequency it should operate? Is this defined by the FlexSPI clock or something else?
Hi @bp1979 ,
Please check the datasheet, you will find the flexSPI clock max situation with the DQS method:
Best Regards,
kerry
So you say that settings MCR0[RXCLKSRC] = 0x0 will set the FlexSPI clock in 60 MHz?
So what does this do then:
Hi @bp1979 ,
You misunderstand me, let me share more details.
1. 60Mhz, MCR0[RXCLKSRC] = 0x0, is the default for the XIP FCB.
Reason: The FLEXSPI_A_DQS pad is not supported by ROM
natively in RT1024, which restricts the maximum FLASH
frequency to 60MHz.
2. To your mentioned, it is the SDK flexspi_nor_polling_transfer project.
In the code, you can use higher than 60Mhz if you init the DQS pin, please check the pin_mux.c, you will find it.
Then, you can use the code to set more than 60Mhz:
All the reason is determined by you define the DQS pin or not.
Wish it helps you!
Best Regards,
Kerry