When i enter vlls3 mode , i measure power comsumption 2xx uA (i use external osc 32768hz),
Where am i setting wrong?
IC: MK02FN64VFM10
Environment: IAR 7,3
My code:
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "pin_init.h"
#include "osa1.h"
#if CPU_INIT_CONFIG
#include "Init_Config.h"
#endif
/* User includes (#include below this line is not maintained by Processor Expert) */
#define SYS_CLOCK 23986176
void SYS_Init(void)
{
OSC_CR = 0xA0;
MCG_C1 = 0x0;
MCG_C2 = 0x06; //
MCG_C4 = 0X80; //32768*732 = 23986176 SYSTEM CLOCK
MCG_C6 = 0;
MCG_C7 = 1; //
MCG_C8 = 0;
SIM_SOPT1 &= ~(3<<18);
SIM_SCGC4 = 0;
SIM_SCGC5 = 0;
SIM_SCGC7 = 0;
WDOG_STCTRLH = 0;
}
void ENTER_VLLS3(void)
{
volatile unsigned int dummyread;
SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;
/* Set the STOPM field to 0b100 for VLLS3 mode */
SMC_PMCTRL &= ~SMC_PMCTRL_STOPM_MASK;
SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x4);
SCB->SCR &= (unsigned int)~(unsigned int)(SCB_SCR_SLEEPONEXIT_Msk);
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
SMC_STOPCTRL = 0x03;
/*wait for write to complete to SMC before stopping core */
dummyread = SMC_PMCTRL;
/* Now execute the stop instruction to go into LLS */
//stop();
asm("WFI");
}
/*lint -save -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
unsigned int i;
PE_low_level_init();
for(i = 0 ; i < 1000000; i++);
SYS_Init();
while(1)
{
ENTER_VLLS3();
}
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
for(;;){}
}
Electric circuit:
