I am using the MK60FN1M0VMD12.
The code for the full clock transition module is pretty big. I use many of the MCG modes in our application.
The particular mode where this gets stuck is a switch from FEI (default) mode to FBE (yes, I am trying to run at 32 kHz).
I am using a crystal connected to Extal32/Xtal32.
The location where my clock switch code gets stuck is here:
if (nextClockSource == Clocking_RTC)
{
// disable OSC0 monitor
MCG_C6 &= ~MCG_C6_CME_MASK;
// disable OCS1 monitor
MCG_C12 &= ~MCG_C12_CME2_MASK;
// enable RTC monitor
MCG_C8 |= MCG_C8_CME3_MASK;
while(1) <----------------- stuck in this loop!!!!!
{
if ((MCG_C8 & MCG_C8_LOCS3_MASK) == 0)
{
break;
}
else
{
MCG_C8 |= MCG_C8_LOCS3_MASK;
for(j = 0; j < 1000000; ++j); // delay
i++;
}
}
}
before this I set the clock monitor to interrupt instead of reset, and I disable the Monitor Interrupt Vector so that I can poll. At this point I have only enabled the RTC, the MCU is still in FEI mode.
Thanks!