Thanks for your help Charles. I don't see what I am missing then. The reference manual says (pg 172)
The core, system, bus and flash clock frequencies and MCG
clocking mode are restricted in this mode. See the Power
Management chapter for the maximum allowable frequencies
and MCG modes supported.
Set PMPROT[AVLP]=1, PMCTRL[RUNM]=10.
Here is BOARD_BootClockVLPR
void BOARD_BootClockVLPR(void)
{
/*
* Core clock: 4MHz
*/
const sim_clock_config_t simConfig = {
.clkdiv1 = 0x00040000U, /* SIM_CLKDIV1. */
};
CLOCK_SetSimSafeDivs();
CLOCK_BootToBlpiMode(0U, kMCG_IrcFast, kMCG_IrclkEnable);
CLOCK_SetSimConfig(&simConfig);
SystemCoreClock = 4000000U;
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
SMC_SetPowerModeVlpr(SMC);
while (SMC_GetPowerModeState(SMC) != kSMC_PowerStateVlpr)
{
}
}
This function seems to do just that...
CLOCK_SetSimSafeDivs just sets the bus/flash clocks to a safe value before the switch.
CLOCK_BootToBlpiMode takes me from FEE to FBI to BLPI (required for VLPR) mode. I know it says boot but I can't see why I can't use it.
CLOCK_SetBlpiMode assumes I am already in FBI mode and I'm not, I'm in FEE mode.
CLOCK_SetSimConfig does the same thing as CLOCK_SetSimSaveDivs but I don't think it's hurting anything.
Then it's sets the SMC just as the reference manual says. I can't see what I am missing.