Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

when put a function in main , the current is about 0.3mA

like this:

bool gm_judge_obd_no_data(void)
{
    if(m_obd_auto_info.rpm > 10)
    {
        return false;
    }

    return true;
}

void gm_vel_dispaly_process(void)

{

    switch(m_vel_dispaly_process)

    {

        case VEL_DIS_PROCESS_SLEEP :

        {

            if(gm_judge_obd_no_data() == false)
            {
                m_vel_dispaly_process = VEL_DIS_PROCESS_AWAKEN_INIT;
            }

        }

        break;

        default :

        break;

    }

}

int main(void)
{
    timer_init();
/*---------------------------------------------------------------------*/
    gm_init_ht16c23();
/*---------------------------------------------------------------------*/
    ble_stack_init();
    gm_set_device_adv_name();

    gap_params_init();
    gatt_init();
    conn_params_init();
/*---------------------------------------------------------------------*/
    db_discovery_init();
    peer_manager_init();

    services_init();
    advertising_init();
    gm_open_dcdc_mode();
    application_timers_start();

    adv_scan_start();

/*---------------------------------------------------------------------*/

    //------------1
    for (;;)
    {

        //------------2

        power_manage();

    }
}

/****************************************************************/

when device sleep, some used peripherals were closed,  m_vel_dispaly_process = VEL_DIS_PROCESS_SLEEP; 

now, in function "gm_vel_dispaly_process();" , change "m_vel_dispaly_process " according to the result of check  "uint8_t m_obd_auto_info.rpm" greater than 10 or not.

if put "gm_vel_dispaly_process();" in "//------------1", current about 0.01mA, however put in "//------------2", current  is 0.3mA.  

even if put "gm_vel_dispaly_process();" in a function for handling timer timeout(1 s), still 0.3mA.  

if delete "power_manage();" in main, modify and put "gm_vel_dispaly_process();" in for(;;){}, current  is 0.3mA.

void gm_vel_dispaly_process(void)

{

    switch(m_vel_dispaly_process)

    {

        case VEL_DIS_PROCESS_SLEEP :

        {

            if(gm_judge_obd_no_data() == false)
            {
                m_vel_dispaly_process = VEL_DIS_PROCESS_AWAKEN_INIT;
            }

            else

            {

                 power_manage();

            }

        }

        break;

        default :

        break;

    }

}

Related