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

nrf_pwr_mgmt_run() with SoftDevice not go to low power

Hello.

I use SDK16 in my project.

Previously when I want to go on sleep I use __WFI(), and get into sleep till interrupt. Because I use The SoftDevice I change the command to nrf_pwr_mgmt_run() as instruct by Nordic . But now it doesn't enter sleep at all. I try also disable the FPU by NRF_PWR_MGMT_CONFIG_FPU_SUPPORT_ENABLED 0 in the sdk_config.h but didn't help.

Why it is so?

Bar.

Parents Reply Children
  • Hi Jored.

    It doesn't stop there because I enable the BLE and the softdevice define SOFTDEVICE_PRESENT. So it go to sd_app_evt_wait()

    Look at the code.

    // Wait for an event.
    #ifdef SOFTDEVICE_PRESENT
    if (nrf_sdh_is_enabled())
    {
    ret_code_t ret_code = sd_app_evt_wait();
    ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED));
    UNUSED_VARIABLE(ret_code);
    }
    else
    #endif // SOFTDEVICE_PRESENT
    {
    // Wait for an event.
    __WFE();
    // Clear the internal event register.
    __SEV();
    __WFE();
    }

    As I see it when it use BLE with SOFTDEVICE and it is enable it should go there.

    Is there a problem about it?

    Bar.

  • Hi,

    Sorry for the confusion, you're absolutely correct. Does it go to the WFE() inside the sd_app_evt_wait()? 

  • Hello Jared.

    As  I look into sd_app_evt_wait() I just get to this function 

    SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));

    But can't get inside. It is look it send and receive interrupt flags from the SD.

    I look on the header explain and I see this:

    In order to wake up from disabled interrupts, the SEVONPEND flag has to be set in the Cortex-M
    MCU's System Control Register (SCR), CMSIS_SCB.

    ... The application must ensure that the pended flag is cleared using ::sd_nvic_ClearPendingIRQ
     in order to sleep using this function. This is only necessary for disabled interrupts

    I can't find anything about sd_nvic_ClearPendingIRQ

    But when look for the SEVONPEND flag I found this discussion: https://devzone.nordicsemi.com/f/nordic-q-a/7107/sevonpend-setting---how-to

    WHere he did some work exactly with the some function I try to handle.

    Where look for https://devzone.nordicsemi.com/f/nordic-q-a/7107/sevonpend-setting---how-to

    So I look for SCB_SCR_SEVONPEND_Msk and the only thing I found was 

    SCB->SCR |= SCB_SCR_SEVONPEND_Msk;

    which is close by #ifdef PWR_MGMT_SLEEP_IN_CRITICAL_SECTION_REQUIRED

    DO I need to open this define?

    I also read comment exactly about some issue with sd_app_evt_wait(void) and excessive current. They all take about the FPU and its interrupt panding. https://devzone.nordicsemi.com/f/nordic-q-a/13670/solved-nrf52-sd_app_evt_wait-will-not-go-to-sleep

    But I try some like

      // 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);
    before
    error_code = sd_app_evt_wait();
    but didn't help.
    What could be the problem?
    Regards
    Bar.
     

     

Related