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

Weird intermittent power spikes during sleep, while monitoring nRF52 DK power with PPK in System ON sleep mode

Hey! I am testing some power consumption of my application, and I need to have a long rest period of appr. 15 minutes. I'm using an RTC timer in System ON sleep mode, full RAM retention, and get a minimum power draw of about 2.3uA. This is good, however I am running the application and measuring current draw with a PPK and I'm noticing fairly frequent 2mA spikes in power draw. It would be ideal if I could get these to go away, I have no idea what is causing them. Here are my relevant function snippets and a screenshot of the PPK data:

This is data taken during a period of sleep ^^

And here are the relevant function snippets (main, my timer init, and timer start function):

/**@brief Application main function.
 */
int main(void)
{
    bool erase_bonds = false;

    // Call function very first to turn on the chip
    turn_chip_power_on();

    log_init();
    power_management_init();

    // Initialize fds and check for calibration values
    fds_init_helper();
    check_calibration_state();

    // Continue with adjusted calibration state
    ble_stack_init();
    timers_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    peer_manager_init();

    // Init long-term data storage buffers
    init_data_buffers();
    
    // Start intermittent data reading <> advertising protocol
    enable_isfet_circuit();
    nrf_delay_ms(10);
    enable_pH_voltage_reading();

    // Enter main loop for power management
    while (true)
    {
        idle_state_handle();
        // If data has been buffered then send accordingly, 
        // waiting for BLE_GATTS_EVT_HVN_TX_COMPLETE in 
        // between packets so the tx buffer is not filled
        if (SEND_BUFFERED_DATA) {
            while(HVN_TX_EVT_COMPLETE == false) { break; }
            send_next_packet_in_buffer();
        }
    } 
}

/**@brief Function for handling the idle state (main loop).
 *
 * @details If there is no pending log operation, then sleep until next the 
 *          next event occurs.
 */
static void idle_state_handle(void)
{
    UNUSED_RETURN_VALUE(NRF_LOG_PROCESS());
    nrf_pwr_mgmt_run();
}

#define DATA_INTERVAL 900000 // 15 minutes in millis
APP_TIMER_DEF(m_timer_id);

/**brief Function to begin 15 minute sleep timer
 */
void start_sleep_timer()
{
    sd_ble_gap_adv_stop(m_conn_handle);
    ret_code_t err_code;

    err_code = app_timer_start(m_timer_id, APP_TIMER_TICKS(DATA_INTERVAL), NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO("TIMER STARTED (single shot) \n");
    NRF_LOG_FLUSH();
}

/**@brief Function for initializing the timer module.
 */
void timers_init(void)
{
    uint32_t err_code;
    err_code = app_timer_init();
    APP_ERROR_CHECK(err_code);
    err_code = app_timer_create(&m_timer_id,
                                APP_TIMER_MODE_SINGLE_SHOT,
                                single_shot_timer_handler);
    APP_ERROR_CHECK(err_code);
}

Basically I read some data, advertise, connect, send data, then go to sleep for 15 minutes (and repeat). I turn off the SAADC and everything correctly because I was previously getting 500uA draw in sleep mode, but then fixed my SAADC shut-off function and got it down to 2.3uA draw now in sleep. It seems rather straightforward, the app_timer should just sleep for 15 minutes and nothing else in the function is called. I do have a compare statement in a while loop in main (compare statement is never true during sleep), so perhaps this could be causing issues? It seems like some sort of compare event is occurring to maybe? There may also be some issue with using the DK as the DUT with the PPK while connected to my PC with usb, and communicating power draw data or something. The spikes do seem rather sporadic, it is not an exact pattern of "every 5 seconds, spike". 

I could also test this on the custom external board I'm developing this application for, but would like to know what the cause of these spikes may be while using the DK. I'm using s112 and SDK V15.2.0

Parents Reply Children
No Data
Related