bmwhui I tried this and it didn't help. In normal run mode the consumption is around 1-2mA which is according to spec, when I run it in VLPR mode power goes down to 300uA, which is slightly higher that it should. Then I try to put it in VLPS and the current goes down to 200uA but not lower. I'm banging my head over this for more than a week, and cannot find a solution.
Here is the code I'm using to put the device to VLPS. This code works perfectly on KL0532 but not on KL0508. on KL0532 I get 1.7uA when I execute this code, on Kl0508 I'm stuck to 200uA.
SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK); // Enable PORTA and PORTB clocks
SMC_PMPROT = SMC_PMPROT_AVLP_MASK |
SMC_PMPROT_ALLS_MASK |
SMC_PMPROT_AVLLS_MASK; /* Setup Power mode protection register */
__asm ("CPSID i"); // Disable interrupts
PORTA_PCR0 = PORT_PCR_MUX(1); // Set PA0 and PA2 SWD pins to GPIO
PORTA_PCR2 = PORT_PCR_MUX(1);
PORTA_PCR1 = PORT_PCR_MUX(1); // Set PA1 reset pin to GPIO
GPIOA_PDDR = 0x7;
GPIOA_PDOR = 0x0;
/* SCB_SCR: SLEEPDEEP=1 */
SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;
SMC_PMPROT = SMC_PMPROT_AVLP_MASK;
/* SMC_PMCTRL: STOPM=0 */
SMC_PMCTRL &= (uint8_t)~(uint8_t)(SMC_PMCTRL_STOPM(0x07));
SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x2);
(void)(SMC_PMCTRL == 0U); /* Dummy read of SMC_PMCTRL to ensure the register is written before enterring low power mode */
/* SCB_SCR: SLEEPONEXIT=0 */
SCB_SCR &= (uint32_t)~(uint32_t)(SCB_SCR_SLEEPONEXIT_MASK);
__asm("WFI");