This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

When enter low power mode,what's the difference between wfi,and wfi sev wfi

I'm using  the code below to enter lp mode;waiting for rtc wake up interrupt to wake up the mcu;

Now I need the app_timer module to do more things ,so I add app_timer lib ,the app timer works good,

but I notice when the timer wakes up,the mcu can't wake up,after processing the app_timer handler ,it is still in lp mode,

but the next time,it will wake the mcu to exit lp mode,then again fail to wake up.

When I change the code to just one WFI function to enter lp mode ,that works good ,it will wake the mcu every time as I want.

So what's the difference between these,how this happen?

I'm not using the lastest sdk ,also not using the softdevice.

__WFI;
__SEV;
__WFI;

__WFI

Thanks!

  • Hi

    What happens is that the __SEV function clears the internal event register, which includes the timer you set, and is why the timer is not waking the application as you want. Not clearing the event register however, will consume more power than just going to sleep will. Also, the __WFI function is short for wait for interrupt, which means the application will sleep until an interrupt event occurs. You could use the __WFE function instead which wakes up on any event.

    Best regards,

    Simon

  • Thanks Simon !

    when using wait for event function,the mcu consumes too much power than __WFI.

    Why didn't clear the internal event register consumes more power?

    Is there any other way to clear it?

    Can I move the __SEV function to the start of application,so  after interrupt wake the application,clear the register first,

    after doing the work,then go to __WFI.

    Or like that:

    __WFI;              //Wait for interrupt
    __SEV;              //Interrupt ocurred ,clear the regirster
    
    //...                 //go to process application

  • Sure you can set the __SEV after __WFI, but I don't think that will do what you want. Please see this post for an accurate explanation on WFE and SEV. And sorry, as my explanation was not correct.

    For the record, if __WFI by itself is sufficient for your application, I think it will be okay to stick with that.

    Best regards,

    Simon

Related