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 */
/* Port C Clock Gate Control: Clock enabled */
/* Port E Clock Gate Control: Clock enabled */
/* 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)
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;
/* WFI instruction will start entry into STOP mode */
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).