Hi Jorge and Mark, thanks for your posts.
Unfortunately it still doesn't work. (It works when I setup PLL to frequency around 60MHz). Also I am using PK66F which pre-release version.
This is my setting procedure, did I forget about something:
// Allow High Speed Run (HSRUN) mode (FLASH write forbidden, no firmware update!)
SMC->PMPROT |= SMC_PMPROT_AHSRUN_MASK;
//Enter HSRUN mode
SMC->PMCTRL |= SMC_PMCTRL_RUNM(3);
// switch on USB first
SIM->SCGC3 |= (SIM_SCGC3_USBHS_MASK | SIM_SCGC3_USBHSPHY_MASK | SIM_SCGC3_USBHSDCD_MASK);
SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK;
// switch on USB 48MHz oscilator
USB0->CLK_RECOVER_IRC_EN |= USB_CLK_RECOVER_IRC_EN_IRC_EN_MASK;
//select MCG Oscillator Reference to IRC48M
MCG->C7 |= MCG_C7_OSCSEL(2);
//ENTER FBE:
MCG->C1 |= MCG_C1_CLKS(2);
//MCG->C1 |= MCG_C1_FRDIV();
MCG->C1 &= ~MCG_C1_IREFS_MASK;
MCG->C6 &= ~MCG_C6_PLLS_MASK;
MCG->C2 &= ~MCG_C2_LP_MASK;
while((MCG->S & MCG_S_IREFST_MASK) != 0)
{
// wait until external reference is current source for the reference clock
;
}
while((MCG->S & MCG_S_CLKST_MASK) >> MCG_S_CLKST_SHIFT != 2)
{
// wait until the external reference clock is selected to feed MCGOUTCLK
;
}
//ENTER PBE:
/* fMCGOUTCLK = (OSCCLK / PLL_R) × M / 2 - this is in new datasheet*/
MCG->C5 = MCG_C5_PRDIV(2); // divide
MCG->C6 |= MCG_C6_VDIV(4); // multiply
MCG->C1 |= MCG_C1_CLKS(2);
//MCG->C1 |= MCG_C1_FRDIV();
MCG->C1 &= ~MCG_C1_IREFS_MASK;
MCG->C6 |= MCG_C6_PLLS_MASK;
MCG->C2 &= ~MCG_C2_LP_MASK;
while((MCG->S & MCG_S_PLLST_MASK) == 0)
{
;
}
while((MCG->S & MCG_S_LOCK0_MASK) == 0)
{
;
}
//ENTER PEE:
MCG->C1 = 0x20;
while((MCG->S & MCG_S_CLKST_MASK) >> MCG_S_CLKST_SHIFT != 3)
{
;
}
SIM->CLKDIV1 = SIM_CLKDIV1_OUTDIV1(1) | SIM_CLKDIV1_OUTDIV2(3) | SIM_CLKDIV1_OUTDIV3(3) | SIM_CLKDIV1_OUTDIV4(6);
//IT CRASHES EXECUTING CODE BELOW THIS LINE