2 Replies Latest reply on Aug 22, 2017 9:38 AM by epr_1639216

    Delay between CyBle_ProcessEvents(), CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP) and CySysPmDeepSleep()?

      Hi everyone!


      My code works and I have not observed a bug (yet), but I was wondering what the recommended / correct sequence is. In pseudo code, I do the following after waking up from any interrupt:


      // Step 1. Woke up from a interrupt. Process BLE events:



      // Step 2. Event close state?

      if(CyBle_GetBleSsState() == CYBLE_BLESS_STATE_EVENT_CLOSE)


          // Update manufacturer specific part of advertisement packet




      // Step 3. Manage BLESS power modes



      // Step 4. ****** Now perform all other tasks; this can take long, e.g. 40 ms ******


      // Step 5. Go into low power sleep mode (redacted example)

      interrupt_status = CyEnterCriticalSection();

      if(CyBle_GetBleSsState() == CYBLE_BLESS_STATE_DEEPSLEEP)






      Please observe step 4 where other tasks are performed and can introduce a long delay between step 3 and step 5.


      Is this correct and the lowest power solution, or must I swap step 3 and step 4 so that CyBle_EnterLPM() is called just before CyEnterCriticalSection()? Why?


      Thanks in advance,