Hello,
the function BOARD_BootClockRUN(); set the Core to VLPR. I used the online tool to generate this code - so it should be correct. Also the status flags indicate that the mcu is in VLPR. I uploaded my project VD8nDummy.zip - Google Drive. I cant build your project - but I will try to fix this later.
One more little thing.
NXP should also correct the datasheet of this MCU in some places there is 1MHz Bus and/or Flash specified for VLPR, but only 800Khz is possible. Also some peripheral clocks described in Table 7-2 "Module operation in low power modes" are wrong calculated with a bus clock of 1Mhz.
#include "fsl_smc.h"
#include "clock_config.h"
#define MCG_PLL_DISABLE 0U
#define OSC_CAP0P 0U
#define OSC_ER_CLK_DISABLE 0U
#define RTC_CLKIN_32768HZ 32768U
#define SIM_OSC32KSEL_RTC32KCLK_CLK 2U
#define SIM_PLLFLLSEL_MCGFLLCLK_CLK 0U
extern uint32_t SystemCoreClock;
const mcg_config_t mcgConfig_BOARD_BootClockRUN =
{
.mcgMode = kMCG_ModeBLPI,
.irclkEnableMode = kMCG_IrclkEnable | kMCG_IrclkEnableInStop,
.ircs = kMCG_IrcFast,
.fcrdiv = 0x0U,
.frdiv = 0x0U,
.drs = kMCG_DrsLow,
.dmx32 = kMCG_Dmx32Default,
.pll0Config =
{
.enableMode = MCG_PLL_DISABLE,
.prdiv = 0x0U,
.vdiv = 0x0U,
},
};
const sim_clock_config_t simConfig_BOARD_BootClockRUN =
{
.pllFllSel = SIM_PLLFLLSEL_MCGFLLCLK_CLK,
.er32kSrc = SIM_OSC32KSEL_RTC32KCLK_CLK,
.clkdiv1 = 0x40000U,
};
const osc_config_t oscConfig_BOARD_BootClockRUN =
{
.freq = 0U,
.capLoad = (OSC_CAP0P),
.workMode = kOSC_ModeExt,
.oscerConfig =
{
.enableMode = OSC_ER_CLK_DISABLE,
}
};
void BOARD_BootClockRUN(void)
{
CLOCK_SetXtal32Freq(RTC_CLKIN_32768HZ);
CLOCK_SetSimSafeDivs();
CLOCK_BootToBlpiMode(mcgConfig_BOARD_BootClockRUN.fcrdiv,
mcgConfig_BOARD_BootClockRUN.ircs,
mcgConfig_BOARD_BootClockRUN.irclkEnableMode);
CLOCK_SetSimConfig(&simConfig_BOARD_BootClockRUN);
SMC_SetPowerModeProtection(SMC, kSMC_AllowPowerModeAll);
#if (defined(FSL_FEATURE_SMC_HAS_LPWUI) && FSL_FEATURE_SMC_HAS_LPWUI)
SMC_SetPowerModeVlpr(SMC, false);
#else
SMC_SetPowerModeVlpr(SMC);
#endif
while (SMC_GetPowerModeState(SMC) != kSMC_PowerStateVlpr)
{
}
SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
}