Hello
I have a question. After when I have used saadc, the consumption increases by 0.9mA. And stays it so. Do you have any idea, how to find out what it does?
saadc init:
ret_code_t err_code; // init saadc nrf_drv_saadc_config_t saadc_conf; saadc_conf.resolution = NRF_SAADC_RESOLUTION_10BIT; saadc_conf.interrupt_priority = APP_IRQ_PRIORITY_LOWEST; saadc_conf.low_power_mode = false; saadc_conf.oversample = NRF_SAADC_OVERSAMPLE_32X; //saadc_conf.oversample = NRF_SAADC_OVERSAMPLE_DISABLED; err_code = nrf_drv_saadc_init(&saadc_conf, saadc_event_handler); //err_code = nrf_drv_saadc_init(&saadc_conf, NULL); APP_ERROR_CHECK(err_code); // battery voltage channel nrf_saadc_channel_config_t batt_channel_conf; batt_channel_conf.resistor_p = NRF_SAADC_RESISTOR_DISABLED; batt_channel_conf.resistor_n = NRF_SAADC_RESISTOR_DISABLED; batt_channel_conf.gain = NRF_SAADC_GAIN1_6; batt_channel_conf.reference = NRF_SAADC_REFERENCE_INTERNAL; batt_channel_conf.acq_time = NRF_SAADC_ACQTIME_3US; batt_channel_conf.mode = NRF_SAADC_MODE_SINGLE_ENDED; batt_channel_conf.burst = NRF_SAADC_BURST_ENABLED; batt_channel_conf.pin_p = NRF_SAADC_INPUT_VDD; batt_channel_conf.pin_n = NRF_SAADC_INPUT_DISABLED; err_code = nrf_drv_saadc_channel_init(0, &batt_channel_conf); APP_ERROR_CHECK(err_code); // motor voltage channel nrf_saadc_channel_config_t motor_channel_conf; motor_channel_conf.resistor_p = NRF_SAADC_RESISTOR_DISABLED; motor_channel_conf.resistor_n = NRF_SAADC_RESISTOR_DISABLED; motor_channel_conf.gain = NRF_SAADC_GAIN1_2; motor_channel_conf.reference = NRF_SAADC_REFERENCE_INTERNAL; motor_channel_conf.acq_time = NRF_SAADC_ACQTIME_3US; motor_channel_conf.mode = NRF_SAADC_MODE_SINGLE_ENDED; motor_channel_conf.burst = NRF_SAADC_BURST_ENABLED; motor_channel_conf.pin_p = NRF_SAADC_INPUT_AIN1; motor_channel_conf.pin_n = NRF_SAADC_INPUT_DISABLED; err_code = nrf_drv_saadc_channel_init(1, &motor_channel_conf); APP_ERROR_CHECK(err_code); // err_code = nrf_drv_saadc_buffer_convert(g_saadc_buffer, SAADC_SAMPLES_IN_BUFFER); // APP_ERROR_CHECK(err_code); nrf_saadc_disable();
battery voltage measurement:
uint16_t GetBatteryVoltageAsInteger(void)
{
uint32_t result, TempVal;
//nrf_saadc_value_t temp_adc_val;
int16_t temp_adc_val;
nrf_saadc_enable();
g_Flag_saadc_new_value = false;
ret_code_t err_code = nrf_drv_saadc_buffer_convert(g_saadc_buffer, SAADC_SAMPLES_IN_BUFFER);
APP_ERROR_CHECK(err_code);
nrf_drv_saadc_sample();
while(!g_Flag_saadc_new_value){};
//nrf_drv_saadc_sample_convert(0, &temp_adc_val);
temp_adc_val = g_saadc_buffer[0];
nrf_saadc_disable();
// temp_adc_val = MeasureBatteryVoltage10bits_buffer();
if(temp_adc_val < 0)
TempVal = 0;
else
TempVal = (uint32_t)temp_adc_val;
result = (uint32_t)(TempVal * 3516) / 1000;
return (uint16_t)result;
}
saadc interrupt:
void saadc_event_handler(nrf_drv_saadc_evt_t const *p_event)
{
if(p_event->type == NRF_DRV_SAADC_EVT_DONE)
{
// ret_code_t err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, SAADC_SAMPLES_IN_BUFFER);
// APP_ERROR_CHECK(err_code);
g_Flag_saadc_new_value = true;
}
}