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

low power saadc

when I start ADC the current will be HIGH .even I UN-Initialization it .

what I have done like that below;

 

#define SAADC_CONFIG_LP_MODE 1

void my_adc_init(void)							
{
		MI_LOG_DEBUG("my_adc_init\r\n");
    ret_code_t err_code;
    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
    APP_ERROR_CHECK(err_code);
	
    nrf_saadc_channel_config_t channel_config0 =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(LIGHT_CHECK);
	channel_config0.reference=NRF_SAADC_REFERENCE_VDD4;
	
    err_code = nrf_drv_saadc_channel_init(LIGHT_CHECK-1, &channel_config0);
    APP_ERROR_CHECK(err_code);
    
	nrf_saadc_channel_config_t channel_config1 =
    NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(BATTRY_CHECK);
    
    err_code = nrf_drv_saadc_channel_init(BATTRY_CHECK-1, &channel_config1);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool,SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
}

void start_ADC(void)
{
	MI_LOG_DEBUG("start_ADC\r\n");
	uint32_t err_code;
	LIGHT_PIN_control(LIGHT_CONTRL_ACTIVE);
	my_adc_init();
	err_code=nrf_drv_saadc_sample();//
	APP_ERROR_CHECK(err_code);
}
void saadc_callback(nrf_drv_saadc_evt_t const * p_event)										
{
    MI_LOG_DEBUG("saadc_callback\r\n");
	static uint32_t count=0;
    ret_code_t err_code;	
	count ++ ;
    if (p_event->type == NRF_DRV_SAADC_EVT_DONE)//ADC转换完成
    {
    	MI_LOG_INFO("the BATTRY  value is  %d . %d V\r\n", battry_V,(battry_V-(unsigned char )battry_V)*100);
		nrf_drv_saadc_uninit();		
	}
	if(p_event->type == NRF_DRV_SAADC_EVT_LIMIT)
	{
		MI_LOG_INFO("ADC  NRF_DRV_SAADC_EVT_LIMIT %d \r\n",count);
	}
	if(p_event->type == NRF_DRV_SAADC_EVT_CALIBRATEDONE)
	{
		MI_LOG_INFO("ADC  NRF_DRV_SAADC_EVT_CALIBRATEDONE %d \r\n",count);
	}
}

before I started it  The current is 0.6ma

but when I start it the current becom 7ma  .

Is there anything else should I do .

IS there any one can help me .

Parents
  • I'm guessing you're not using the DCDC regulator and not putting the CPU to sleep after starting the SAADC. Do you mind posting the relevant code to your SAADC usage?

  • I‘ve tried open dcdc .it downs to 3.75ma

    but what make me puzzled is that      :start the SAADC or not ,the current could chang so much .

    start :3.75ma

    no start :0.7ma

     I start SAADC  and then it finsh check    I UN-Initialized the SAADC but it always be high current .

    I give my main fuction below

    int main(void)
    {
        uint32_t err_code;
        ble_stack_init();
    	power_first();			
        gap_params_init();
        my_service_Init();
        advertising_init();
        conn_params_init();
    
    //    printf("\r\nUART Start!\r\n");
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    	My_flash_init();
    	get_save_and_synchronous_num();	
        // Enter main loop.
        for (;;)
        {
    		if (NRF_LOG_PROCESS() == false)
    		{
    			if(My_Time_Fuction_Enable==1)// changes pro min
    			{
    				My_Time_Fuction_Process();
    				My_Time_Fuction_Enable=0;
    			}
            power_manage();
    		}
        }
    }
    //most time it wait event until one minite.
    
    
    
    void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
    {
    ...
        nrf_drv_saadc_uninit();	
    ...
    }
    
    
    //stars pro min
    void start_ADC(void)
    {
    	MI_LOG_DEBUG("start_ADC\r\n");
    	uint32_t err_code;
    	LIGHT_PIN_control(LIGHT_CONTRL_ACTIVE);
    	my_adc_init();
    	err_code=nrf_drv_saadc_sample();//
    	APP_ERROR_CHECK(err_code);
    }
    // if I Shielded this code   the current would be 0.7ma .
    // or it will be 3.75ma
    
    
    

    SAADC starts pro minite .and after it finished I  UN-Initialized the SAADC.

Reply
  • I‘ve tried open dcdc .it downs to 3.75ma

    but what make me puzzled is that      :start the SAADC or not ,the current could chang so much .

    start :3.75ma

    no start :0.7ma

     I start SAADC  and then it finsh check    I UN-Initialized the SAADC but it always be high current .

    I give my main fuction below

    int main(void)
    {
        uint32_t err_code;
        ble_stack_init();
    	power_first();			
        gap_params_init();
        my_service_Init();
        advertising_init();
        conn_params_init();
    
    //    printf("\r\nUART Start!\r\n");
        err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
        APP_ERROR_CHECK(err_code);
    	My_flash_init();
    	get_save_and_synchronous_num();	
        // Enter main loop.
        for (;;)
        {
    		if (NRF_LOG_PROCESS() == false)
    		{
    			if(My_Time_Fuction_Enable==1)// changes pro min
    			{
    				My_Time_Fuction_Process();
    				My_Time_Fuction_Enable=0;
    			}
            power_manage();
    		}
        }
    }
    //most time it wait event until one minite.
    
    
    
    void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
    {
    ...
        nrf_drv_saadc_uninit();	
    ...
    }
    
    
    //stars pro min
    void start_ADC(void)
    {
    	MI_LOG_DEBUG("start_ADC\r\n");
    	uint32_t err_code;
    	LIGHT_PIN_control(LIGHT_CONTRL_ACTIVE);
    	my_adc_init();
    	err_code=nrf_drv_saadc_sample();//
    	APP_ERROR_CHECK(err_code);
    }
    // if I Shielded this code   the current would be 0.7ma .
    // or it will be 3.75ma
    
    
    

    SAADC starts pro minite .and after it finished I  UN-Initialized the SAADC.

Children
No Data
Related