AnsweredAssumed Answered

Failure to enter VLPS on KL17

Question asked by Mitchell Jones on Jul 13, 2019
Latest reply on Jul 15, 2019 by Mitchell Jones

I'm having trouble getting the KL17 to enter VLPS mode. I'm wanting to enter VLPS and wake on interrupt from a gpio pin...

I do SMC->PMPROT = SMC_PMPROT_AVLP_MASK; in my initialization code.

Also I disable the following before sleep (and re enable after):

-- the clock disables I figured would be enough for all pins and stuff on those ports.

/* Port B Clock Gate Control: Clock enabled */
CLOCK_DisableClock(kCLOCK_PortB);
/* Port C Clock Gate Control: Clock enabled */
CLOCK_DisableClock(kCLOCK_PortC);
/* Port E Clock Gate Control: Clock enabled */
CLOCK_DisableClock(kCLOCK_PortE);
/* PORTA1 (pin 11) is configured as LPUART0_RX */
PORT_SetPinMux(PORTA, 1U, kPORT_PinDisabledOrAnalog);
/* PORTA2 (pin 12) is configured as LPUART0_TX */
PORT_SetPinMux(PORTA, 2U, kPORT_PinDisabledOrAnalog);

Code I call to try to go to sleep:

static void gotosleep(void)
{
prepsleep();
deepsleep();
}

static void prepsleep(void)
{
volatile unsigned int dummyread;
/* 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 = dummyread;
}

void deepsleep (void)
{
/* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
#ifdef CMSIS
__wfi();
#else
/* WFI instruction will start entry into STOP mode */
asm("WFI");
#endif
}

 

The behavior is that the code just steps past WFI and keeps running. I'd appreciate any times (other than the inevitable suggestion from that one user to use uTasker).

 

Regards!

Outcomes