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

Current consumption difference between GNU and IAR builds

I am experiencing a difference in current between the example program during advertising between a IAR compilation and a GNU compilation.

The differences appear to be significant in a range of 10x more power for the GNU during advertising.

  • That seems unlikely. With correct power management advertising current is dominated by the radio and not the CPU core.

  • Seeing the numbers would also be helpful, they can some times indicate what is running or not.
    As Turbo is saying, the choice of compiler shouldn't have such a big impact on current consumption. If you see a huge difference I am inclined to think that the power management is not working properly with one of the compilers.

  • The full code is ble_app_pwr_profiling/main.c. I didn't want to have to push any buttons so I made a minor change.

    int main(void)
    {
        //    ret_code_t err_code;
        //    bool is_notification_mode    = false;
        //    bool is_non_connectable_mode = false;
    
        timers_init();
        buttons_init();
        
    #if 0
    #if BUTTONS_NUMBER > 2
        // Check button states.
        // Notification Start button.
        is_notification_mode = bsp_board_button_state_get(NOTIF_BUTTON_ID);
    
        // Non-connectable advertisement start button.
        if (!is_notification_mode)
        {
            is_non_connectable_mode = bsp_board_button_state_get(NON_CONN_ADV_BUTTON_ID);
        }
        else
        {
            // Un-configured button.
        }
    #else
        is_notification_mode = true;
    #endif
    #endif
        
        // Initialize SoftDevice.
        ble_stack_init();
    
    #if 0
        if (!is_notification_mode && !is_non_connectable_mode)
        {
            // The startup was not because of button presses. This is the first start.
            // Go into System-Off mode. Button presses will wake the chip up.
            err_code = sd_power_system_off();
            APP_ERROR_CHECK(err_code);
        }
    #endif
        
        // If we reach this point, the application was woken up
        // by pressing one of the two configured buttons.
        gap_params_init();
        gatt_init();
    
    #if 1
        // Notification button is pressed. Start connectable advertisement.
        connectable_adv_init();
        service_add();
    #else
        if (is_notification_mode)
        {
            // Notification button is pressed. Start connectable advertisement.
            connectable_adv_init();
            service_add();
        }
        else
        {
            non_connectable_adv_init();
        }
    #endif
        
        advertising_data_init();
        advertising_start();
    
        // Enter main loop.
        for (;;)
        {
            power_manage();
        }
    }
    

    The numbers taken for the IAR were done by someone else, and I don't recall the exact amount of current. The current for the version compiled with gcc was around 200uA.

  • Hi

    Are you sure that the IAR test was done on the same hardware and firmware?

    Can you plug your advertising settings into the online power profiler, and see how the numbers compare? 200uA could be normal for advertising, if the advertising interval is short.

    Best regards

Related