I am using KL15Z128VLM4 for my project. I am trying to switch from RUN to VLPS mode in order to get power consumption down to 12uA or below. Data sheet (KL15P80M48SF0) states that power consumption should be between 3.75uA to 8.46 uA for temperature of 25 deg C and 6.66 uA to 13.41 for 50 deg C. MCU in normal mode runs with 24 MHz and Flash is at 12 MHz. When I am switching to VLPS mode, I am switching to internal fast reference clock at 4 MHz. I am switching to internal clock as follows,
MCG_C1 = MCG_C1_IRCLKEN_MASK | MCG_C1_CLKS(0x01) | MCG_C1_IREFSTEN_MASK;
MCG_C2 = MCG_C2_IRCS_MASK;
MCG_SC = 0;
// Change the clock source for TMP to MCGIRCLK
TPM0_SC = 0;
SIM_SOPT2 &= ~SIM_SOPT2_TPMSRC_MASK;
SIM_SOPT2 |= SIM_SOPT2_TPMSRC(0x03);
While I am in VLPS mode, my requirement is to be able to run TPM0 at 100 KHz. I confirmed the TPM0 is available at VLPS mode.
I configured the TPM0 before I go into VLPS mode.
The rest of the code follows,
// disable clock monitors
MCG_C6 &= ~MCG_C6_CME0_MASK;
//------------------------------------------
// Disable clock gate to the peripheral
//------------------------------------------
// Disable SPI1, SPI0, CMP, UART2, UART1, UART0, I2C1, I2C0
SIM_SCGC4 = 0;
// Disable PORTC, PORTB, PORTA, TSI, LPTMR; Keep PORTE (for TPM output) and
// PORTD
SIM_SCGC5 = 0x00003000;
// Disable DAC0, ADC0, TPM2, TPM1, PIT, DMAMUX; Keep RTC (for wakeup
// periodically), TPM0 (for 100 KHz PWM Pulse), FTF (for flash)
SIM_SCGC6 = 0x21000001;
// Disable DMA
SIM_SCGC7 = 0x0;
/* PMPROT is write once after RESET allows the MCU to enter the VLPR, VLPW, and VLPS modes. */
SMC_PMPROT = SMC_PMPROT_AVLP_MASK;
/* Set the STOPM field to 0b010 for VLPS mode */
SMC_PMCTRL &= ~SMC_PMCTRL_STOPM_MASK;
SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x2);
/*wait for write to complete to SMC before stopping core */
dummyread = SMC_PMCTRL;
dummyread++;
/* Wait for VLPR regulator mode to be confirmed */
for (i = 0 ; i < 10000 ; i++)
{
/* check that the value of REGONS bit is not 0
once it is a zero we can stop checking */
if ((PMC_REGSC & PMC_REGSC_REGONS_MASK) ==0x04)
{
/* 0 Regulator is in stop regulation or in transition
to/from it
1 MCU is in Run regulation mode */
}
else
{
break;
}
}
/* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;
// // Note: https://community.nxp.com/thread/447684?commentID=890323#comment-890323
// // blog suggested to turn off FTF to achieve 33uA
// // Controls the clock gate to the flash memory.
// SIM_SCGC6 &= ~SIM_SCGC6_FTF_MASK;
/* WFI instruction will start entry into STOP mode */
asm("WFI");
If I do exactly what is above, I get 170uA; can't lower power less than that. Where as if I uncomment the line of code to clear the FTF (above blog suggested), MCU is reset upon wakeup. I have set an RTC to wakeup every 30 second . I am not sure why I can't lower the current below 12uA. And why FTF would reset the MCU if the blog suggested that IVAN Santana was able to. Do I have to execute from RAM upon awaken by RTC, and enable the FTF from there?
Thank you for your answer.
Hi,
What's the mask set of your MKL15Z128VLM4? The errata file of KL15 shows below errata info:
Thank you for the attention.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi,
If I understood correctly, you are asking the bit mask set for STOP mode. To answer your question,
I have set the enabled the bit mask to allow for All Low power mode as follows,
SMC_PMPROT = SMC_PMPROT_AVLP_MASK;
Then, I set the bitmask to enter into VLPS mode as follows,
SMC_PMCTRL &= ~SMC_PMCTRL_STOPM_MASK;
SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x2);
Thanks for looking into the question.
Hi,
The mask set I mentioned is the chip surface silk print info (below chip mask set is 1N83J as an example):
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Ma,
Mask set is 2N97F.
Thank you.
Hi,
Thank you for the info.
I would recommend customer to refer FRDM_KL25Z board provide [low_power_demo] to let your KL15 chip enter into VLPS mode and then measure the power consumption.
The [FRDM-KL25Z and TWRKL25Z48M Sample Code Package] could be downloaded from here.
Please let us know the test result. Thanks.
Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------