Hello
I made many test and something is strange.
In default configuration provided in MQX (v4.1.1), the used PLL for MCGOUTCLK is the PLL0 which is configured to 120MHz.
The PLL1 is configured to 150MHz and used for DDR.
Is somebody can confirm this?
The code is following in
__pe_initialize_hardware:
...
/* MCG_C5: PLLREFSEL0=0,PLLCLKEN0=0,PLLSTEN0=0,??=0,??=0,PRDIV0=4 */
MCG_C5 = (uint8_t)0x04U;
/* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=8 */
MCG_C6 = (uint8_t)0x08U;
/* MCG_C11: PLLREFSEL1=0,PLLCLKEN1=0,PLLSTEN1=0,PLLCS=0,??=0,PRDIV1=3 */
MCG_C11 = (uint8_t)0x03U;
/* MCG_C11: PLLCLKEN1=1 */
MCG_C11 |= (uint8_t)0x40U; /* Enable the PLL */
/* MCG_C12: LOLIE1=0,??=0,CME2=0,VDIV1=8 */
MCG_C12 = (uint8_t)0x08U;
while((MCG_S & MCG_S_IREFST_MASK) != 0x00U) { /* Check that the source of the FLL reference clock is the external reference clock. */
}
while((MCG_S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
}
/* Switch to PBE Mode */
/* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=8 */
MCG_C6 = (uint8_t)0x48U;
while((MCG_S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
}
while((MCG_S & MCG_S_LOCK0_MASK) == 0x00U) { /* Wait until PLL locked */
}
/* Switch to PEE Mode */
/* MCG_C1: CLKS=0,FRDIV=5,IREFS=0,IRCLKEN=0,IREFSTEN=0 */
MCG_C1 = (uint8_t)0x28U;
while((MCG_S & 0x0CU) != 0x0CU) { /* Wait until output of the PLL is selected */
}
/* MCG_C6: CME0=1 */
MCG_C6 |= (uint8_t)0x20U; /* Enable the clock monitor */
/*** End of PE initialization code after reset ***/
With this code, I put in a ground loop a pin toggle. The time is about 200ns to execute it.
-1) If I change MCG_C5 from 0x4 to 0x3 this could generate PLL0 to 150MHz instead of 120MHz. => The time to toggle bit is about 175ns => Ok Cpu frequency is increased.
But with this, like USB use only PLL0 we can't reach 48MHz exactly.
-2) By previous test, we can consider PLL0 is Ok because all run correctly, but MCG_C5.PLLCLKEN0 is set to 0 = PLL0 not enabled!!! ??? So what this RUN???
-3) Now the idea is to keep PLL0 to 120MHz and PLL1 to 150MHHz (MQX original configuration) and just switch MCGOUTCLK from PLL0 (120MHz) to PLL1 (150MHz) to increase core/bus... from 120MHz to 150MHz like my CPU is a K70F150M.
To do that, I just changed the configuration of MCG_11 from 0x03 to 0x13 (PLLCS = 1 => use PLL1 not PLL0).
If I do that, the code stay block on the following test:
while((MCG_S & MCG_S_LOCK0_MASK) == 0x00U)...
Like PLL0 was not enable (and it is TRUE!!) But why this Run when PLL0 is selected for MCGOUTCLK???