I am using the next configuration in System_Init() (attached 2 files):
// Initialize PLL0
// PLL0 will be the source for MCG CLKOUT so the core, system, FlexBus, and flash clocks are derived from it
mcg_clk_hz = pll_initialization(OSCINIT, // Initialize the oscillator circuit
OSC_0, // Use CLKIN0 as the input clock
CLK0_FREQ_HZ, // CLKIN0 frequency
LOW_POWER, // Set the oscillator for low power mode
CLK0_TYPE, // Crystal or canned oscillator clock input
PLL_0, // PLL to initialize, in this case PLL0
PLL0_PRDIV, // PLL predivider value
PLL0_VDIV, // PLL multiplier
MCGOUT); // Use the output from this PLL as the MCGOUT
// Check the value returned from pll_initialization() to make sure there wasn't an error
if (mcg_clk_hz < 0x100)
while(1);
// Initialize PLL1
// PLL1 will be the source for the DDR controller, but NOT the MCGOUT
pll_1_clk_khz = (pll_initialization(NO_OSCINIT, // Don't init the osc circuit, already done
OSC_0, // Use CLKIN0 as the input clock
CLK0_FREQ_HZ, // CLKIN0 frequency
LOW_POWER, // Set the oscillator for low power mode
CLK0_TYPE, // Crystal or canned oscillator clock input
PLL_1, // PLL to initialize, in this case PLL1
PLL1_PRDIV, // PLL predivider value
PLL1_VDIV, // PLL multiplier
PLL_ONLY) / 1000); // Don't use the output from this PLL as the MCGOUT
My system all time stay in STOP mode and wake up on RTC alarm. Therefore I want to reduce MCU frequency to minimal power consumption before STOP mode and on RTC Wake up restore to working frequency.
Thanks.
Evgeni