Hi,
I am trying to use the SAADC to periodically sample an input from AIN0 and send the resultant data over a BLE link to a phone. Going through the forums I saw that the ble_app_proximity is a good example of this so I went ahead to try and understand how it is designed.
In a nutshell, to my understanding, it is using a timer to call the nrf_drv_saadc_sample()
function and when complete as signalled by NRF_DRV_SAADC_EVT_DONE
the resultant data is converted and transmitted.
Within the adc_configure()
function there is the following:
err_code = nrf_drv_saadc_buffer_convert(&adc_buf[0],1);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_saadc_buffer_convert(&adc_buf[1],1);
APP_ERROR_CHECK(err_code);
According to SAADC documentation in infocenter, this is explained as:
The driver supports double buffering, which means that nrf_drv_saadc_buffer_convert can be called twice and the buffer that is provided in the second call will be used immediately after the first one is filled.
So this is clear to me that the second buffer will be used if the first one is filled - which is called double buffering here. But later in the saadc_event_handler
there is another call err_code = nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer,1)
I am unable to understand what this call does (even though the documentation says that this is the setup for continuous conversion. Can someone please explain this in a little more detail?
My questions are basically as follows:
-
When sampling an input voltage, my first result goes to
adc_buf[0]
and only if it is full (because I haven't read it?) it will go toadc_buf[1]
.. is that how it is supposed to be? -
What does the call
nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer,1)
do within thesaadc_event_handler
? -
If I don't set up double buffering i.e. only have a single call as below, what will happen? And will I still need a call to this function in the event handler?
err_code = nrf_drv_saadc_buffer_convert(&adc_buf[0],1);