I setup my adc in continuous mode with sampling rate set to 200ksps, when I trigger NRF_SAADC_TASK_START, I am not getting data; unless I trigger NRF_SAADC_TASK_SAMPLE and put a delay after. I am using SDK 16.3
Is there a way to setup a trigger for adc event done without having to wait using nrf_delay?
ret_code_t err_code;
nrf_saadc_value_t buffer[200];
nrf_saadc_channel_config_t channel_config =
NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0);
channel_config.gain = NRF_SAADC_GAIN1_3;
channel_config.acq_time = NRF_SAADC_ACQTIME_3US;
channel_config.mode = NRF_SAADC_MODE_SINGLE_ENDED;
memset(buffer, 0, 200);
nrf_saadc_enable();
nrf_saadc_channel_init(0, &channel_config);
nrf_saadc_buffer_init(buffer, 200);
nrf_saadc_continuous_mode_enable(80);
if(!nrf_saadc_enable_check())
return 1;
nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
while(!nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED));
nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
/*
* Without task trigger task sample and a delay adc does not
* provide data
*/
//nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
//nrf_delay_ms(1);
nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);
while(!nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED));
nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
while (!nrf_saadc_event_check(NRF_SAADC_EVENT_END));
nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
#if 1
for (int loop = 0; loop < 200; loop++) {
if ((buffer[loop] > 10) || (buffer[loop] < -10))
{
NRF_LOG_RAW_INFO("%d, %d,\n", loop, buffer[loop]);
NRF_LOG_FLUSH();
}
}
#endif