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?

Parents
  • I cannot think of anything.very specific.

    Please check if you are hit by ERRATA  78 or 87 as mentioned here

  • Hi,

    I checked ERRATA 87 - CPU: Unexpected wake from System ON Idle when using FPU, according to the Workaround the following code need to be added before calling WFE 

    #if (__FPU_USED == 1)
     _set_FPSCR(_get_FPSCR() & ~(0x0000009F)); 
     (void) __get_FPSCR();
     NVIC_ClearPendingIRQ(FPU_IRQn);
    #endif

    Does this code need to be added also before calling sd_app_evt_wait? ( I'm using SOFTDEVICE)

    however, I tried to add this before calling sd_app_evt_wait but it didn't help

    Any other suggestions?

  • Hi Shai,

    That seems to be a lot of current from a peripheral keeping the HFCLK ON. That is not normal and is not consistent with the testing I have done here on the examples.

    Are you testing this on nRF52833 DK board or is it a custom board? Have you disabled all tasks in your application and let the idle task run only  to see how much current the idle application consumes?

  • Hi

    I'm using nRF52833 DK running ble_app_hrs_freertos example.

    1. when using the following code:

            if ( xModifiableIdleTime > 0 )
            {
    #ifdef SOFTDEVICE_PRESENT
                if (nrf_sdh_is_enabled())
                {
    #if (__FPU_USED == 1)
                 __set_FPSCR(__get_FPSCR() & ~(0x0000009F)); 
                 (void) __get_FPSCR();
                 NVIC_ClearPendingIRQ(FPU_IRQn);
    #endif  __FPU_USED
                    uint32_t err_code = sd_app_evt_wait();
                    APP_ERROR_CHECK(err_code);
                }
                else
    #endif  // SOFTDEVICE_PRESENT
                {
                    /* 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]));
                }
            }

    the average power consumption is: 5.794mA

    sd_app_evt_wait

    2. when using the following code (forcing to use WFE):

            if ( xModifiableIdleTime > 0 )
            {
    #if 0
    #ifdef SOFTDEVICE_PRESENT
                if (nrf_sdh_is_enabled())
                {
    #if (__FPU_USED == 1)
                 __set_FPSCR(__get_FPSCR() & ~(0x0000009F)); 
                 (void) __get_FPSCR();
                 NVIC_ClearPendingIRQ(FPU_IRQn);
    #endif  __FPU_USED
                    uint32_t err_code = sd_app_evt_wait();
                    APP_ERROR_CHECK(err_code);
                }
                else
    #endif  // SOFTDEVICE_PRESENT
    #endif  // if 0
                {
                    /* 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]));
                }
            }

    the average power consumption is: 102uA

    WFE

    Which example did you test?

    Thanks, Shai

  • 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. 

Reply Children
Related