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

nRF52, problem reading SAADC - AIN7

I'm having problems reading channel AIN7 in the rRF52, SDK11

I configure every channel in a similar way:

//adc_channel_5
{
	nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN5);
	channel_config.gain = NRF_SAADC_GAIN1_4;
	channel_config.reference = NRF_SAADC_REFERENCE_VDD4;
	channel_config.acq_time = NRF_SAADC_ACQTIME_10US;
	err_code = nrf_drv_saadc_channel_init(NRF_SAADC_INPUT_AIN5, &channel_config);
	APP_ERROR_CHECK(err_code);
}

//adc_channel_6
{
	nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN6);
	channel_config.gain = NRF_SAADC_GAIN1_4;
	channel_config.reference = NRF_SAADC_REFERENCE_VDD4;
	channel_config.acq_time = NRF_SAADC_ACQTIME_10US;
	err_code = nrf_drv_saadc_channel_init(NRF_SAADC_INPUT_AIN6, &channel_config);
	APP_ERROR_CHECK(err_code);
}

//adc_channel_7
{
	nrf_saadc_channel_config_t channel_config = NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN7);
	channel_config.gain = NRF_SAADC_GAIN1_4;
	channel_config.reference = NRF_SAADC_REFERENCE_VDD4;
	channel_config.acq_time = NRF_SAADC_ACQTIME_10US;
	err_code = nrf_drv_saadc_channel_init(NRF_SAADC_INPUT_AIN7, &channel_config);
	APP_ERROR_CHECK(err_code);
}	

and the function for reading each of the channels is the same:

// adc_driver_read_channel
return_t adc_driver_read_channel(uint8_t in_channel, int16_t *out_value){
	return_t result = ok;
	nrf_saadc_value_t aux_value;
	while(nrf_drv_saadc_sample_convert(in_channel, &aux_value) != NRF_SUCCESS){};
	*out_value = (int16_t)aux_value;
	if (*out_value >= 4000){
		result = adc_error_overflow;
	}
	return result;
}

but, for some reason every other channel works without problem but this one keeps returning the same value. I have physically checked the entry pin and the input value is correct.

Am I missing something? is some special configuration needed for this pin?

Thanks in advance.

Related