I am using a nRF52 and I have to measure two voltages:
-
the first continuously
-
when a command is received, the second voltage have to be measured and then switch back to measure the first
I initialize the saadc driver, configure two channels, initialize the first (nrf_drv_saadc_channel_init) then I start a timer. When the timer fires I call the nrf_drv_saadc_sample() to acquire the voltage in the saadc callback. Everything works as expected.
Problems arise when I try to switch to the second channel. On command received, I stop the timer and I try to switch to the second channel:
err_code = nrf_drv_saadc_channel_uninit(1);
if (err_code == NRF_ERROR_BUSY) {
NRF_LOG_DEBUG("\tBUSY on uninit\n");
}
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_saadc_channel_init(0, &ch2_config);
if (err_code == NRF_ERROR_BUSY) {
NRF_LOG_DEBUG("\tBUSY on init\n");
}
APP_ERROR_CHECK(err_code);
I always get NRF_ERROR_BUSY calling nrf_drv_saadc_channel_uninit(1).
What's the right way to switch between channels?
I have seen a lot of examples on measuring two or more voltages but they switch between channels one after the other.
Thank you in advance.