This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[SOLVED] nRF52: sd_app_evt_wait() will not go to sleep

I'm having a strange problem, where sd_app_evt_wait() won't make the CPU sleep, after I've started a app_timer (consuming >2mA). Its working perfectly before I've started it, only dragging around ~1uA.

Im using the nRF5 11.0.0 SDK with the s132 softdevice (on NRF52832).

Any ideas what may be causing this? Or how I can make it sleep while the timer is running?

EDIT: I'm pretty sure the app_timer_start i'm using is stopping the CPU from sleeping. I thought the CPU could sleep, when using the app_timers? Im using a timer that makes a callback run every 10 seconds. It will not sleep while this timer is running...

  • The application timer uses the RTC so it should not cause the CPU to remain on.

    What are you doing in the timer callback? Are you sampling any ADCs?

    If so there is a known issue resulting in high current consumption when using nrf_drv_saadc_buffer_convert(), see this thread: devzone.nordicsemi.com/.../

    There is also a known issue with the FPU interrupts: infocenter.nordicsemi.com/index.jsp

        ** FPU **
    - When the FPU is in use, it triggers the FPU_IRQn interrupt when one of
      the six exception flags (IDC, IXC, UFC, OFC, DZC, IOC) is set.
      The FPU interrupt will always set the pending flag (even if the 
      interrupt is not enabled), irrespective of whether the user is 
      interested in the exception bit.
      The pending flag then prevents the SoftDevice from going into low 
      power mode when sd_app_evt_wait() is called.
      Therefore, always clear the exception bits and the pending interrupt 
      before calling sd_app_evt_wait(). See the code below for an example 
      implementation.
      FPU exception bit definition:
      infocenter.arm.com/.../index.jsp
      Example code:
      {
      // Set bit 7 and bits 4..0 in the mask to one (0x ...00 1001 1111)
      #define FPU_EXCEPTION_MASK 0x0000009F 
     
      ...
          /* Clear exceptions and PendingIRQ from the FPU unit */
          __set_FPSCR(__get_FPSCR()  & ~(FPU_EXCEPTION_MASK));      
          (void) __get_FPSCR();
          NVIC_ClearPendingIRQ(FPU_IRQn);
     
          /* Call SoftDevice Wait For event */
          error_code = sd_app_evt_wait();
      }
    

    Let me know if it helps.

  • Thanks for the reply, James! I've studied the problem a bit further, and it appears the CPU is unable to go to sleep after a the timer callback is called. In this callback, I'm not sampling ADC, but i'm using a couple of GPIO commands, like nrf_gpio_pin_read and nrf_gpio_pin_write. Only GPIO is used in the callback.

    The sd_app_evt_wait will not be able to make the CPU sleep, if any of the interrupt pending flags are enabled. Could there be some interrupt flags that has to be cleared manually, even if it's not used? I'm going to try clearing the FPU_IRQn-flag before sleeping.

  • Maybe try commenting out all code in the callback handler, that way you can isolate the problem down to GPIO operation or timer callback.

    Also are you using the scheduler for the timer?

  • If you're having FPU interrupt issues, are they the same ones as in this thread

    devzone.nordicsemi.com/.../

  • That's right! It was the FPU :-) All good now. Solved!

Related