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

When open the SAADC, it cannot be closed in the low power

Hi

I open the SAADC to get the battery after initial the SAADC, using nrf_drv_saadc_sample_convert to get the ADC data . After nRF52832 is initialed, it enter power_manage, but the cutrrent cannot enter low power(about 6.8mA),because the SAADC cannot be closed.  If I don't use the nrf_drv_saadc_sample_convert function after saadc_init, the current could be entered low power. Thus, nrf_drv_saadc_sample_convert is the key. So, how to control SAADC when MCU enter the low power.

The code is as following:

void saadc_init(void)
{
ret_code_t err_code;
nrf_saadc_channel_config_t mmysaadc1=
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);
//NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(SAADC_CH_PSELP_PSELP_VDD);//VDD
nrf_saadc_channel_config_t mmysaadc=
//NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(SAADC_CH_PSELP_PSELP_VDD);//VDD


err_code=nrf_drv_saadc_init(NULL,saadc_callback);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_saadc_channel_init(0, &mmysaadc);
APP_ERROR_CHECK(err_code);
// err_code = nrf_drv_saadc_channel_init(1, &mmysaadc1);
// APP_ERROR_CHECK(err_code);
}

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

***********************************************************************************************/
nrf_saadc_value_t saadc_val;//, saadc_val1;
float voltage=9.99;
int init_ADC_battary(void)
{
       ret_code_t err_code;
      saadc_init(); //
       nrf_drv_saadc_sample_convert(0,&saadc_val);
       voltage=(float)saadc_val*3.6/1024;
       vol_send_phone = (uint8_t)(voltage * 10);
}

void main()

{

...................

      init_ADC_battary();
// Start execution.
      NRF_LOG_INFO("Blinky example started.");
      advertising_start();

// Enter main loop.
      for (;;)
      {
            if (NRF_LOG_PROCESS() == false)
            {
                  power_manage();
            }
      }

}

Thanks.

Parents
  • Have you tried the lower power mode? NRFX_SAADC_CONFIG_LP_MODE in sdk_config.h

    I can't see why you would only get high current when you are using float, but 6.8mA indicates to me that the CPU is still running. The ADC would not prevent the CPU from going to sleep, so maybe you end up in an error handler? Have you checked the err_code variable? You should also check the value returned by nrf_drv_saadc_sample_convert.

Reply
  • Have you tried the lower power mode? NRFX_SAADC_CONFIG_LP_MODE in sdk_config.h

    I can't see why you would only get high current when you are using float, but 6.8mA indicates to me that the CPU is still running. The ADC would not prevent the CPU from going to sleep, so maybe you end up in an error handler? Have you checked the err_code variable? You should also check the value returned by nrf_drv_saadc_sample_convert.

Children
No Data
Related