AnsweredAssumed Answered

Entering VLLS0 mode

Question asked by Chip Weller on Nov 12, 2015
Latest reply on Nov 12, 2015 by Mark Butcher

We have a device which is using VLLS0 mode for sleeping. One of three GPIO / LLWU pins can wake the device, either on a single edge or on both depending on the pin. Both the sleep and wake operations work fine. There is a possible race condition when putting the device to sleep, where an external user action causes a pin to transition just before the WFI instruction. I am not sure how to handle this.


The processor is the MKL16Z256V. I have read AN4503 section 14.1.2 but that does not address all my concerns.


If I capture the transition on an edge, I still have to avoid executing the WFI instructions to have the system successfully respond to the user. My reading of section 14.1.2 suggests that the WFI instruction will be aborted if the interrupt occurs "just" before the instruction.


Q1: Does this cause the WFI instruction to reset the processor (the normal way out of VLLS0) or does it simply start executing the instruction following the WFI?


My current thought is when preparing to sleep:

  1. Set a flag.
  2. Check if no work required (which may have been queued before the flag was set). If work required, abort the enter VLLS0 operation and continue normal operation.
  3. In the ISRs if the flag is set when the edge occurs, force a reset.
  4. Enter the VLLS0 mode using WFI.
  5. [If execution continues past the WFI then force a reset.]


I have a way to address passing the edge information back to the main line after the reset, allowing for processing after the reset.


Q2: Is there anything missing from this approach?


Q3: Does anyone have a better approach?


Thanks in advance,