Hi Evgeny Erenburg,
Your problem is still caused by your configuration.
Please refer to the TWR-K70F120M sample code from the official website:
Kinetis 120MHz bare metal sample code
If you compare with your code, it is not difficult to find your problem:
1.
mcg_clk_hz = pll_init(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 */
MCGOUT); /* Don't use the output from this PLL as the MCGOUT */
2.
mcg_clk_hz = pll_init(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 */
Please check the head file on your side:
#define PLL0_PRDIV 5
#define PLL0_VDIV 24
#define PLL1_PRDIV 5
#define PLL1_VDIV 30
The parameter is not the same.
So, if you want to get the 12Mhz core clock, just refer to the official sample code:
mcg_clk_hz = pll_init(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 */
Wish it helps you!
If you still have question, please contact me!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------