Does unblocked saadc sample the buffer size and stop or does it start re-sampling after the callback? In other words, if the buffer is 100 entries in length, will it issue a callback every 100 samples, continuously. The documentation isn't clear.
Does unblocked saadc sample the buffer size and stop or does it start re-sampling after the callback? In other words, if the buffer is 100 entries in length, will it issue a callback every 100 samples, continuously. The documentation isn't clear.
SentinelLighting said:-WHERE does your documentation say this? From what I have read it does not say that.
An exempt of the very first sentence of the Continuous mode documentation reads:
Continuous sampling can be achieved by using the internal timer in the ADC, or triggering the SAMPLE task from one of the general purpose timers through the PPI.
So unless you are using the internal timer you will have to have the SAMPLE task be triggered externally, such as by the CPU directly (which likely will not generate a accurate periodic sampling) or through PPI. What else do you interpret this sentence to mean?
The case in which you are using the internal timer lets you trigger SAMPLE only once, but this is only available for single channel sampling.
SentinelLighting said:The documentation implies you call nrfx_saadc_sample ONCE and it will then issue the callback when the 25 samples are complete! This is where the documentation is confusing.
This is only the case when using the internal SAADC timer for sampling of a single channel. The relevant section from the continuous mode documentation reads:
The SAMPLERATE register can be used as a local timer instead of triggering individual SAMPLE tasks. When SAMPLERATE.MODE is set to Timers, it is sufficient to trigger SAMPLE task only once in order to start the SAADC and triggering the STOP task will stop sampling. The SAMPLERATE.CC field controls the sample rate.
If you would like to use the driver for this you will have to use the nrfx_saadc_v2's advanced mode. Using the advanced mode of the nrfx_saadc_v2 driver to do continuous sampling using the internal timer is demonstrated in this example.
SentinelLighting said:Are saying I have to call nrfx_saadc_sample 25 times, waiting in between calls for the adc to convert?
If you are neither using the internal timer nor an external event to trigger the sampling you will have to call this function 25 times, correct. This is however not the recommended way of capturing a series of periodic samples, as previously mentioned.
SentinelLighting said:That is basically blocking mode!
No, what you do in-between calls to nrfx_saadc_sample is up to you.
Best regards,
Karl
Again, the documentation doesn't say you need to setup an internal timer to trigger samples. To me (and other people who have read this documentation) "Sampling" implies multiple samples, not just one! You are basically saying that the nrfx_saadc_sample will only create one sample in 'cpu mode' if no timer is set up, despite the fact that the nrfx_saadc_buffer_convert allows you to setup a buffer with NUM_SAMPLES (25 in my case!). The implications is that nrfx_saadc_buffer_convert sets up the 'unblocked' mode to do multiple samples! I don't understand how you don't see that this is confusing
SentinelLighting said:Again, the documentation doesn't say you need to setup an internal timer to trigger samples.
I would argue that it does, in the very first line of the continuous mode documentation:
Karl Ylvisaker said:An exempt of the very first sentence of the Continuous mode documentation reads:
Continuous sampling can be achieved by using the internal timer in the ADC, or triggering the SAMPLE task from one of the general purpose timers through the PPI.
Followed up by:
Karl Ylvisaker said:The SAMPLERATE register can be used as a local timer instead of triggering individual SAMPLE tasks. When SAMPLERATE.MODE is set to Timers, it is sufficient to trigger SAMPLE task only once in order to start the SAADC and triggering the STOP task will stop sampling. The SAMPLERATE.CC field controls the sample rate.
I would say that this clearly states that it is sufficient to trigger the SAMPLE task only once in the case that you are working with an internal timer to achieve continuous sampling. Thus, in the case that you are not using the internal timer you should trigger the SAMPLE task externally, such as by a TIMER instance over PPI.
SentinelLighting said:You are basically saying that the nrfx_saadc_sample will only create one sample in 'cpu mode' if no timer is set up, despite the fact that the nrfx_saadc_buffer_convert allows you to setup a buffer with NUM_SAMPLES (25 in my case!). The implications is that nrfx_saadc_buffer_convert sets up the 'unblocked' mode to do multiple samples! I don't understand how you don't see that this is confusing
I am indeed saying that nrfx_saadc_sample will only create 1 sample - if not used with the internal timer.
Readying a buffer and filling said buffer is two entirely separate operations, I would argue.
I might of course be biased because I have worked with this for some time now, but I cant say that it would make sense to have the SAADC fill up a provided buffer without specifying in any capacity the interval or frequency of these samples. For most any signal processing purposes these measurements would be useless since you do not know the frequency the samples are sampled at. Is this not a fair assessment?
I do see how 'sampling' could imply more than one sample, but I guess this then refers to the case in which the internal timer is used - since there exists a case in which triggering SAMPLE once is sufficient to perform multiple samples - but seen in light of the continuous mode documentation I would not say that this is ambiguous.
If you have a specific suggestion for an improvement of the documentation we would of course welcome any such feedback!
Best regards,
Karl