AnsweredAssumed Answered

Wake from LLS

Question asked by Magnus Nilsson on Oct 21, 2015
Latest reply on Jan 18, 2016 by Benny Goodman

I'm trying to wake a MKL17Z256Vxx4 from LLS on external pin, following the "bare metal" example in AN4503 ch 4.1.

Entering LLS works (i.e. code execution stops), but it won't wake up.

The code below is for port C3(LLWU_P7), since I have a simple push button connected to it, but I've also attempted port C5(LLWU_P9).

AN4503 says: "If interrupts are disabled, the execution resumes with the instruction after the WFI, or STOP instruction."

- so I assume I don't have to use a LLWU_IRQHandler (even though I've tried that too).

 

void main(void){

    for (uint8_t i = 0; i < HW_PORT_INSTANCE_COUNT; i++){

        CLOCK_SYS_EnablePortClock(i);

    }

 

    SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;

    PORTC_PCR3 =(PORT_PCR_ISF_MASK |

    PORT_PCR_MUX(01) |

    PORT_PCR_IRQC(0x0B) | //either edge interrupt enable

    PORT_PCR_PE_MASK |

    PORT_PCR_PS_MASK);

 

    //SIM_SCGC4 = SIM_SCGC4_LLWU_MASK; // does not exist in Kinetis L ?

    LLWU_PE2 = 0xC0; //WPU07 either edge

 

    //MCG_C6 &= ~MCG_C6_CME0_MASK; // not for Kinetis L ?

 

    SMC_PMPROT = 0x08;

    SMC_PMCTRL |= 0x03;

    volatile unsigned int dummyread = SMC_PMCTRL;

    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

    asm("WFI");

    //now in LLS - does however not wake up when PC3 is toggled

 

    //snip some code that lights an LED to show that the MCU woke up

 

    while(1){}

}

 

 

I would be very grateful for a sniplet of code that successfully enters and exits LLS on Kinetis L.

Outcomes