I would like a simple way to read the voltage on one ADC pin without using any "adc_event_handler"-like solution.
but without success.
First of all, event-driven ADC is recommended, so that the CPU can be turned off during inactive periods. But if you don’t want that, here is a very simple way to read the ADC without using any events…
First of all, event-driven ADC is recommended, so that the CPU can be turned off during inactive periods. But if you don’t want that, here is a very simple way to read the ADC without using any events, using the nrf_drv_adc_sample_convert function:
static nrf_adc_value_t adc_value; /**< ADC buffer. */
static nrf_drv_adc_channel_t m_channel_config = NRF_DRV_ADC_DEFAULT_CHANNEL(NRF_ADC_CONFIG_INPUT_2);
* @brief Function for main application entry.
NRF_LOG_PRINTF("ADC buffer: %d\r\n",adc_value);
/** @} */
how long does it take to have a measurement ready?
Can I shorten the nrf_delay_ms() to 10ms (of course after removing the UART)?
How long time before the measurement is ready depend on what bit mode you use on the ADC.
The default configuration uses 10-bit, and takes 68 μs to sample. If you use 8-bit mode it takes 20 μs (50K samples per second). The nrf_delay_ms() is just there to not overflow the uart.
Can you convert this example to sdk16? I am having trouble converting it myself.
Thanks a lot!