I have a MKL27 that I want to put in to Very Low Leakage Stop mode 3 (VLLS3).
I am using the code below. The Power Mode Status register always indicates that the mode always remains 'Run'.
Does anyone see what I might have wrong with the code below?
SMC_PMPROT is a write once register and it is not being written anyplace else in the system.
/* One time write - allow VLPR, LLS and VLLS modes */
/* Setup Power mode protection register */
SMC_PMPROT = SMC_PMPROT_AVLP_MASK | /* Allow Very-Low-Power Modes */
SMC_PMPROT_AVLLS_MASK | /* Allow Very-Low-Leakage Stop Mode */
SMC_PMPROT_ALLS_MASK; /* Allow Low-Leakage Stop Mode */
SMC_PMCTRL = SMC_PMCTRL_STOPM(4); /* 4 = Very Low Lekage Stop VLLSx */
SMC_STOPCTRL = SMC_STOPCTRL_VLLSM(3); /* 3 = VLLS3 */
SCB_SCR = SCB_SCR_SLEEPDEEP_MASK; /* Deep Sleep = 1, SLEEPONEXIT = 0 = do not sleep when returning to Thread mode */
(volatile uint8_t) SMC_PMCTRL; /* Dummy read to ensure the register is written before entering low power mode */
while( 0U != (SMC_PMSTAT & 0x01) )/* Blink as long as remain in RUN mode */
delay_ms( 100U );