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

Related