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

App unusual current draw

I am facing a strange situation with my app. After turning off all my peripherals and switching to the most minimal code, I see quite a lot of current consumption and that too erratic. 

My minimal code is this:

int main(void)
{
    timers_init();
    power_management_init();
    ble_stack_init();
    sd_power_dcdc_mode_set(1);

    for (;;) {
        nrf_pwr_mgmt_run();
    }
}

The corresponding current graph observed is:

For roughly a minute, there is 500-600uA being drawn at quite a high frequency and it then stops. Then there are smaller current draws  and an occasional large spike. 

I don't really know what is causing the initial current draw, and would appreciate some inputs on getting rid of them. Does this current graph look like something I should expect from the code snippet? My app code is actually just what is in the snippet above.

I get a similar behavior with my test app, where I have an adc measurement and twi reads, it seems the app is getting some interrupts causing it to wake up between expected intervals. The advertising interval I have set is 5s and ADC read is 4s, but the current graph shows the following:

The interval at which the current increases is not making sense to me, as it is much lower than either the 5s advertising or 4s adc sampling interval. It settles only after a while. The code snippet is something like this:

static void timers_init(void)
{
    ret_code_t err_code;

    // Initialize timer module
    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);

    err_code = app_timer_create(&m_saadc_timer_id,
                                APP_TIMER_MODE_REPEATED,
                                saadc_meas_timeout_handler);

    APP_ERROR_CHECK(err_code);
}

static void timer_start(void)
{
    ret_code_t err_code;

    err_code = app_timer_start(m_saadc_timer_id, APP_TIMER_TICKS(4000), NULL);
    APP_ERROR_CHECK(err_code);
}

static void connectable_adv_init(void)
{
    memset(&m_adv_params, 0, sizeof(m_adv_params));

    m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_IND;
    m_adv_params.p_peer_addr = NULL;                               // Undirected advertisement
    m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
    m_adv_params.interval    = MSEC_TO_UNITS(5000, UNIT_0_625_MS);
    m_adv_params.timeout     = 0;
}

static void saadc_meas_timeout_handler(void * p_context)
{
    // m_timeout = true;
            saadc_init();
            ret_code_t err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAADC_SAMPLES_IN_BUFFER);
            APP_ERROR_CHECK(err_code);
            nrf_drv_saadc_sample();
}


int main(void)
{
    timers_init();
    power_management_init();

    // initialize SoftDevice.
    ble_stack_init();
    sd_power_dcdc_mode_set(1);

    // set up I2C
    twi_init(&m_twi);

    peer_manager_init();
    gap_params_init();
    gatt_init();
    services_init();
    conn_params_init();

    connectable_adv_init();
    timer_start();
    advertising_start();

    // Enter main loop.
    for (;;) {


        nrf_pwr_mgmt_run();

    }
}

How can I debug this?

Parents Reply Children
Related