Hi All
I'm trying to use the Adc in Sample convert mode: "nrfx_saadc_sample_convert(0,&ADC_Val);" to sequential read two ADC pins .
I have used the code below to init the saadc with a single channel. and changing the Analog pin "nrf_saadc_channel_pos_input_set () "
My question is how to change the pin of the ADC in the code below the pin didn't change post init function.
Also can you please explain if I need to use the" busy =nrfx_saadc_is_busy()" function, to verify that the ADC is clear for another sample?
please advise.
void saadc_init_convert(void)
{
uint32_t err_code;
nrf_saadc_channel_config_t channel_config = NRFX_SAADC_DEFAULT_CHANNEL_CONFIG_SE(chanel_num);
err_code = nrfx_saadc_init(NULL, saadc_callback);
APP_ERROR_CHECK(err_code);
channel_config.gain = NRF_SAADC_GAIN1_6;
err_code = nrf_drv_saadc_channel_init (0, &channel_config);
APP_ERROR_CHECK(err_code);
}
int main(void)
{
while (1)
{
nrf_saadc_channel_pos_input_set (0,NRF_SAADC_INPUT_AIN0);
err_code =nrfx_saadc_sample_convert(0,&ADC_Val[0]);
APP_ERROR_CHECK(err_code);
// change mux control
nrf_saadc_channel_pos_input_set (0,NRF_SAADC_INPUT_AIN2);
err_code =nrfx_saadc_sample_convert(0,&ADC_Val[1]);
APP_ERROR_CHECK(err_code);
}
}