Does SEV() clear or set the Event register? and why do we use it between two WFE() calls?
__WFE();
__SEV();
__WFE();
Does SEV() clear or set the Event register? and why do we use it between two WFE() calls?
__WFE();
__SEV();
__WFE();
Update: Corrected answer.
Yes. SEV signals an event. WFE, on the other hand, will put the CPU to sleep and wait for an event, then wake up and clear the event. If the event was already set, WFE will clear the event and return it immediately.
This way of using two WFE calls is a power-optimization. See this thread and this post for details.
now i understand it's sev()+wfe() that clears the event register not sev() only, thanks
Please see also my comment here: devzone.nordicsemi.com/.../ Think twice when are you clearing event flag - the safe place for that operation really depends on the requirements and code itself.