AnsweredAssumed Answered

How to add a sleep function and wait for interrupt to wake?

Question asked by Albert Zhou on Dec 5, 2019
Latest reply on Dec 13, 2019 by Albert Zhou

I try to add a sleep function to reduce the MKL27Z644 power current. Code as below:

 

 

void sleep(void);

 

main()

{

initial();

SMC->PMPRORT =-1;      //added for sleep mode

while(1)

{

 processing();

sleep();                      //enter sleep for LPUART interrupt to wake up into rum mode.

}

 

}

void sleep(void)

{

 SCB->SCR &=~SCB_SCR_SLEEPDEEP_MASK;

SMC->PMCTRL = BIT6;   //RUNM VLPR;

_enable_irq();

//asm("WFI");

_ISB();

}

 It is not work at all. I don't know how to make this to work. I could not add the line 'asm("WFI") that disables LPUART interrupt.

Outcomes