Hello,
I start from the power management demo unde the SDK library:
Freescale\KSDK_1.3.0\examples\frdmk22f\demo_apps\power_manager_hal_demo
I try to simplify this demo to have only the system in run mode at 20MHz then enter in VLLS2 mode and wakeup using RTC each 1second.
so I modify the configuration for enter RUN mode to have Core clock = 20MHz :
in board.c file :
!
/* Configuration for enter RUN mode. Core clock = 80MHz. */
const clock_manager_user_config_t g_defaultClockConfigRun =
{
.mcgConfig =
{
.mcg_mode = kMcgModePEE, // Work in PEE mode.
.irclkEnable = true, // MCGIRCLK enable.
.irclkEnableInStop = false, // MCGIRCLK disable in STOP mode.
.ircs = kMcgIrcSlow, // Select IRC32k.
.fcrdiv = 0U, // FCRDIV is 0.
.frdiv = 0U,//3U,
.drs = kMcgDcoRangeSelLow, // Low frequency range
.dmx32 = kMcgDmx32Default, // DCO has a default range of 25%
.oscsel = kMcgOscselOsc, // Select OSC
.pll0EnableInFllMode = false, // PLL0 disable
.pll0EnableInStop = false, // PLL0 disalbe in STOP mode
.prdiv0 = 0x3U,
.vdiv0 = 0x10U,
},
.simConfig =
{
.pllFllSel = kClockPllFllSelPll, // PLLFLLSEL select PLL.
.er32kSrc = kClockEr32kSrcRtc, // ERCLK32K selection, use RTC.
// .outdiv1 = 0U,
// .outdiv2 = 1U,
// .outdiv3 = 2U,
// .outdiv4 = 3U,
.outdiv1 = 4U,
.outdiv2 = 4U,
.outdiv3 = 4U,
.outdiv4 = 4U,
},
.oscerConfig =
{
.enable = true, // OSCERCLK enable.
.enableInStop = false, // OSCERCLK disable in STOP mode.
.erclkDiv = 0U, // OSCERCLK divider setting.
}
};
then I modify the define in the board.h file
#ifndef CLOCK_INIT_CONFIG
#define CLOCK_INIT_CONFIG CLOCK_RUN
#endif
#if (CLOCK_INIT_CONFIG == CLOCK_RUN)
#define CORE_CLOCK_FREQ 40000000U
#elif (CLOCK_INIT_CONFIG == CLOCK_HSRUN)
#define CORE_CLOCK_FREQ 120000000U
#else
#define CORE_CLOCK_FREQ 4000000U
#endif
and the main.c as attached.
but the issue it that I have the VLLS2 eash 2 second and note 1second and am note sure if I have the right senario with run at 20MHz then VLLS2 the wakeup each 1s
Could yoy please help me to implement this
Thank you
Nesrine
Make sure that you have no floating inputs (set as outputs or use pull-ups/-downs) since these can otherwise cause higher current consumption: Set continuously to VLSS2 mode and touch all pins whilst monitoring the current - if the current measurement fluctuates it means that such an effect is present.
Regards
Mark
any help
Sorry for the late reply!
Do you mean when you select RTC Alarm interrupt as Wakeup sources and configure it wakeup after 1s.
But the MCU wakeup every 2s?
Have you try to select RTC Second interrupt as Wakeup sources?
The RTC is clock by the 32768Hz crystal,should not be impact by your core clock configuration modify.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Robin,
Thank you for your reply , am able now to have the RTC wake each 1s
and I configure may VLLS2 as follow:
volatile unsigned int dummyread;
SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;
SMC_PMCTRL &= ~SMC_PMCTRL_STOPM_MASK ;
SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x4) ;
SMC_STOPCTRL &= ~SMC_STOPCTRL_LLSM_MASK;
SMC_STOPCTRL |=SMC_STOPCTRL_LLSM(0x2);
dummyread = SMC_STOPCTRL;
/* Set the SLEEPDEEP bit to enable deep sleep mode - enter stop mode*/
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
but the issue that i have 75µA instead of 1.9µA stated in datasheet.
what can be the cause of this higher consumption? could you please help me.
Thank you nesrine.