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

Power consumption using FreeRTOS

Hi,

I'm using an application with FreeRTOS, nRF52833, SDK 16.

When I'm trying to get it into low power (sleep mode) the system still consumes ~4mA

In vPortSuppressTicksAndSleep (port_cmsis_systick.c file) I forced to use WFE instead sd_app_evt_wait

#if 0  
    #ifdef SOFTDEVICE_PRESENT  
    if (nrf_sdh_is_enabled())  
    {  
        uint32_t err_code = sd_app_evt_wait();  
        APP_ERROR_CHECK(err_code);  
    }  
    else  
#endif  
    #endif  
    {  
        /* No SD -  we would just block interrupts globally. 
        * BASEPRI cannot be used for that because it would prevent WFE from wake up. 
        */  
        do{  
            __WFE();  
        } while (0 == (NVIC->ISPR[0] | NVIC->ISPR[1]));  
    }  

After changing it the power consumption was reduced by ~3.5mA

What is the proper way to fix this problem?

  • I am sorry, I realized that my new nRF52833 board did not have the SB bridge cut to make the power measurement.

    In your latest reply you say that you see a significant improvement with WFE, then this is something we saw before

    I suspect that this is because of the use of MWU inside of sd, that causes this spike as seen in this thread. 

    Try disabling the MWU before sd_app_event_wait and enabling just after wakeup in the port_cmsis_systick.c file like below

    // replace sd_app_evt_wait with
    /* MWU Disable */
    NRF_MWU->REGIONENCLR
        = ((MWU_REGIONENCLR_RGN0WA_Clear << MWU_REGIONENCLR_RGN0WA_Pos) 
         | (MWU_REGIONENCLR_PRGN0WA_Clear << MWU_REGIONENCLR_PRGN0WA_Pos));
    
    sd_app_evt_wait();
    
    /* MWU Enable */
    NRF_MWU->REGIONENSET
        = ((MWU_REGIONENSET_RGN0WA_Set << MWU_REGIONENSET_RGN0WA_Pos) 
         | (MWU_REGIONENSET_PRGN0WA_Set << MWU_REGIONENSET_PRGN0WA_Pos));

    I have not tested this since myself, but if this did not work, then I can fix my board and try to dig a bit deeper into it tomorrow.

  • Thanks for your answer, but disabling and then enabling the MWU didn't change the power consumption 

    I will be glad if you will test it

    Thanks

  • I am sorry for coming back late. I am struggling a bit trying to make the SDK16 SES freertos_hrs project run on pca10100.

    • Just changing the preprocessing defines
    • replacing startupfiles to match nrf52833
    • and fixing linker values seems not enough.

    Can I please get your project that runs on pca10100 on sdk16, so that I flash and see the results in the power profiler. 

  • Hi Shai,

    Verified your descritption. You were right. Something is causing the softdevice wakeup too early. Please replace the sd_app_evt_wait with the below code in port_cmsis_systick.c. I have verified my suggestion to improve the power. We will investigate further if this behaviour is same with the coming SD versions to see if we need to fix something.

            if ( xModifiableIdleTime > 0 )
            {
    #ifdef SOFTDEVICE_PRESENT
                if (nrf_sdh_is_enabled())
                {
                    do{
                      uint32_t err_code = sd_app_evt_wait();
                      APP_ERROR_CHECK(err_code);
                    } while (0 == (NVIC->ISPR[0] | NVIC->ISPR[1]));
                }

Related