Unfortunately adding those two lines ('translated' to the API I'm using) didn't do anything, as far as I can see.
//IRQ4_7_PRIORITY_REGISTER = 0x400000000; // set Int ID 7 (LLWU module) to priority 1 ->
NVIC_SetPriority(LLWU_IRQn, 1);
//IRQ0_31_SER = 0x00000080; // enable Interrupt 7 (LLWU module) source ->
NVIC_EnableIRQ(LLWU_IRQn);
It still hangs in LLS.
Doesn't anyone have a working code sniplet how to use the LLWU for KL17?
The full code I'm trying here:
---
int main(void)
{
__asm("CPSID i"); //turn off all interrupts
//IRQ4_7_PRIORITY_REGISTER = 0x400000000; // set Int ID 7 (LLWU module) to priority 1
NVIC_SetPriority(LLWU_IRQn, 1);
//IRQ0_31_SER = 0x00000080; // enable Interrupt 7 (LLWU module) source
NVIC_EnableIRQ(LLWU_IRQn);
for (uint8_t i = 0; i < HW_PORT_INSTANCE_COUNT; i++){
CLOCK_SYS_EnablePortClock(i);
}
//configure LEDs
PORT_HAL_SetMuxMode(RED_LED_PORT, RED_LED_PIN_NBR, kPortMuxAsGpio);
GPIO_DRV_ClearPinOutput(RED_LED_PIN);
GPIO_DRV_SetPinDir(RED_LED_PIN, kGpioDigitalOutput);
PORT_HAL_SetMuxMode(GREEN_LED_PORT, GREEN_LED_PIN_NBR, kPortMuxAsGpio);
GPIO_DRV_ClearPinOutput(GREEN_LED_PIN);
GPIO_DRV_SetPinDir(GREEN_LED_PIN, kGpioDigitalOutput);
//light only GREEN LED
GPIO_DRV_WritePinOutput(RED_LED_PIN, 0b00000000);
GPIO_DRV_WritePinOutput(GREEN_LED_PIN, 0b00000001);
SIM_SCGC5 |= SIM_SCGC5_PORTC_MASK;
PORTC_PCR3 =(PORT_PCR_ISF_MASK |
PORT_PCR_MUX(01) |
PORT_PCR_PE_MASK |
PORT_PCR_PS_MASK);
//wait until button PC3 is pressed - to ensure pin working and correctly configured as input
while(GPIO_DRV_ReadPinInput(BUTTON_PIN)){};
//light only RED LED
GPIO_DRV_WritePinOutput(RED_LED_PIN, 0b00000001);
GPIO_DRV_WritePinOutput(GREEN_LED_PIN, 0b00000000);
SMC_PMPROT = 0x08;
SMC_PMCTRL |= 0x03;
volatile unsigned int dummyread = SMC_PMCTRL;
LLWU_PE2 = 0xC0; //WPU07 either edge
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
asm("WFI");
//Should sleep here (it does),
//and wake up on button PC3 press (it does not)
if (LLWU_F1 & LLWU_F1_WUF7_MASK) {
LLWU_F1 |= LLWU_F1_WUF7_MASK;
//light only GREEN LED
GPIO_DRV_WritePinOutput(RED_LED_PIN, 0b00000000);
GPIO_DRV_WritePinOutput(GREEN_LED_PIN, 0b00000001);
} else {
//light RED and GREEN LED
GPIO_DRV_WritePinOutput(RED_LED_PIN, 0b00000001);
GPIO_DRV_WritePinOutput(GREEN_LED_PIN, 0b00000001);
}
while(1){}