OK, so I have my program running and it has the following features:
- KL03 running off internal 2 MHz LIRC in VLPR mode
- LPTMR running generating interrupts every 200 mS and being serviced by an ISR callback
- Two pins, PTA0 and PTB0 configured as inputs with weak pull down, these were chosen because they are also LLWU_P7 and LLWU_P4
Currently, the program loops around a while(1) loop until an interrupt occurs and the stae of the buttons is tested during every interrupt. I now want to implement VLLS3 (or VLLS2) so that I save power; the LPTMR will keep running because it's using the 1kHz Low Power Clock as its prescalerClockSource. The low power guide example (p19) says I need to:
- Configure a GPIO pin that will be used to wake from LLS mode.
- Configure pin as digital input
- Configure LLWU module pin PORTC6 (LLWU_P10) as a valid wake-up source.
My pins are already set up as digital inputs and they are generating interrupts so I think 2 is covered. But for 1 I need to set up the LLWU so that either pin will wake up the LLWU, the example code I'm looking at is this...
SIM_HAL_EnableLlwuClock(SIM_BASE, HW_LLWU); // this bit may not exist on some MCUs
LLWU_HAL_ClearExternalPinWakeupFlag(LLWU_BASE, 10u);
//falling edge detection
LLWU_HAL_SetExternalInputPinMode(LLWU_BASE, kLlwuExternalPinFallingEdge, kLlwuWakeupPin10);
so if I keep the first 2 statements and then use this statement...
LLWU_HAL_SetExternalInputPinMode(LLWU_BASE, kLlwuExternalPinRisingEdge, kLlwuWakeupPin4);
I think I'll set the LLWU to wake up from one pin but if I then say
LLWU_HAL_SetExternalInputPinMode(LLWU_BASE, kLlwuExternalPinRisingEdge, kLlwuWakeupPin7);
will that make both pins work or just one?
I also want to use the LPTMR interrupt to wake up but I now think this is not set in the LLWU, it's simply done by enabling the interrupt for the LPTMR and this is already done in the LPTMR initialization so am I good to go on that matter?
Any guidance for the steps I'll need to follow when I wake up are welcome; when the LPTMR interrupt causes an LLWU wakeup, I think I need to clear the interrupt for the LLWU first in a separate callback and then allow the normal LPTMR ISR to run. Assuming I'm right on this, what re-initialization will I need to perform?