大学生
最后登录1970-1-1
在线时间 小时
注册时间2018-4-3
|
发表于 2018-10-23 13:18:26
|
显示全部楼层
从火哥提供的NXP官方 Flashloader代码里我扣出来了这些代码, 看起来是PFD480_PFD0, 具体看代码
[mw_shl_code=c,true]// FLEXSPI clock configuration, safe frequency: 30MHz
CCM->CSCMR1 = ((CCM->CSCMR1 &
~(CCM_CSCMR1_FLEXSPI_CLK_SEL_MASK | CCM_CSCMR1_FLEXSPI_PODF_MASK | CCM_CSCMR1_PERCLK_PODF_MASK |
CCM_CSCMR1_PERCLK_CLK_SEL_MASK)) |
CCM_CSCMR1_FLEXSPI_CLK_SEL(3) | CCM_CSCMR1_FLEXSPI_PODF(7) | CCM_CSCMR1_PERCLK_PODF(1));
void flexspi_clock_config(uint32_t instance, uint32_t freq, uint32_t sampleClkMode)
{
uint32_t pfd480 = 0;
uint32_t cscmr1 = 0;
uint32_t frac = 0;
uint32_t podf = 0;
typedef struct _flexspi_clock_param
{
uint8_t frac;
uint8_t podf;
} flexspi_clock_param_t;
const flexspi_clock_param_t k_sdr_clock_config[kFlexSpiSerialClk_200MHz + 1] = {
// Reserved, 30MHz 50MHz 60MHz 75MHz 80MHz 100MHz 133MHz 166MHz 200MHz
{ 0, 0 }, { 34, 8 }, { 22, 8 }, { 24, 6 }, { 30, 4 }, { 18, 6 }, { 14, 6 }, { 17, 4 }, { 26, 2 }, { 22, 2 }
};
const flexspi_clock_param_t k_ddr_clock_config[kFlexSpiSerialClk_200MHz + 1] = {
// Reserved, 30MHz, 50MHz, 60MHz, 75MHz, 80Mhz, 100MHz, 133MHz, 166MHz, 200MHz
{ 0, 0 }, { 24, 6 }, { 22, 4 }, { 12, 6 }, { 30, 2 }, { 18, 3 }, { 22, 2 }, { 33, 1 }, { 26, 1 }, { 22, 1 }
};
do
{
if ((sampleClkMode != kFlexSpiClk_SDR) && (sampleClkMode != kFlexSpiClk_DDR))
{
break;
}
pfd480 = CCM_ANALOG->PFD_480 & (~CCM_ANALOG_PFD_480_PFD0_FRAC_MASK);
cscmr1 = CCM->CSCMR1 & (~CCM_CSCMR1_FLEXSPI_PODF_MASK);
// Note: Per ANALOG IP Owner's recommendation, FRAC should be even number,
// PODF should be even nubmer as well if the divider is greater than 1
const flexspi_clock_param_t *flexspi_config_array = NULL;
if (sampleClkMode == kFlexSpiClk_SDR)
{
flexspi_config_array = &k_sdr_clock_config[0];
}
else
{
flexspi_config_array = &k_ddr_clock_config[0];
}
if (freq >= kFlexSpiSerialClk_30MHz)
{
if (freq > kFlexSpiSerialClk_200MHz)
{
freq = kFlexSpiSerialClk_30MHz;
}
frac = flexspi_config_array[freq].frac;
podf = flexspi_config_array[freq].podf;
pfd480 |= CCM_ANALOG_PFD_480_PFD0_FRAC(frac);
cscmr1 |= CCM_CSCMR1_FLEXSPI_PODF(podf - 1);
FLEXSPI->MCR0 |= FLEXSPI_MCR0_MDIS_MASK;
flexspi_clock_gate_disable(instance);
if (pfd480 != CCM_ANALOG->PFD_480)
{
CCM_ANALOG->PFD_480 = pfd480;
}
if (cscmr1 != CCM->CSCMR1)
{
CCM->CSCMR1 = cscmr1;
}
flexspi_clock_gate_enable(instance);
FLEXSPI->MCR0 &= ~FLEXSPI_MCR0_MDIS_MASK;
}
else
{
// Do nothing
}
} while (0);
}[/mw_shl_code] |
|