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:
Solved! Go to Solution.
Hi herol,
Sorry for my later reply, I already find the root problem.
Please do the modification like the following picture:
Just modify the
#define SYSTEM_SMC_PMPROT_VALUE | 0x00U |
to
#define SYSTEM_SMC_PMPROT_VALUE | 0xAAU |
You can find this defination in system_MK02F128.h, the path is: project path->SDK->device->mk02f12810->startup folder.
Then add the ENTER_VLLS3 code, after you download the code to your chip, unconnect your debugger, repower on your board, you will find the power consumption is about 2uA.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
About the cpu type change error, just like your picture, click switch configuration, then generate the code again and build, the error will be disappeared.
About the PE project download problem, because I don't have K02 , I can't try it, I just try it on my K22, it can use PE multilink to download the code both in barebone project and PE project.
OK. I started to use is no problem , just do not know what set , which led to this situation.
Thanks.
No any error.
I tried many times to go to create a new PE project, and also re-install KDS, but the problem still exists .
Hi herol,
I still find the PE project have higher power consumption, but I still didn't find which code caused it, I am still finding it, when I find the problem, I will let you know.
Your question of downloading maybe caused by the low power mode, you can choose the mass erase on connect an try again.
Regards,
Jingjing
Is there any news?
herol
Hi Jingjing,
Is there any further information?
Thanks.
herol
Hi Jingjing,
Expect you to quickly find the problem.
I found the PE project enters debug mode will have an error message,
but non-PE project is ok.
Thanks.
herol