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.
Do you have example code for how unblocked saadc works? When I execute the following code, it takes 100ms for the saadc_callback to be called! By by calculations it should take only 100 MICRO seconds.
1) Initialize the saadc by calling nrf_drv_saadc_init()... which calls nrfx_saadc_init()
parameters: NULLP, saadc_callback
2) Initialize saadc channel by calling nrf_drv_saadc_channel_init() ... which calls nrfx_saadc_channel_init()
configuration data:
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
.gain = NRF_SAADC_GAIN1_4, \
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
.acq_time = NRF_SAADC_ACQTIME_3US, \
.mode = NRF_SAADC_MODE_SINGLE_ENDED, \
.pin_p = MON_VBOOST, \
.pin_n = NRF_SAADC_INPUT_DISABLED \
3) Start conversions using nrfx_saadc_buffer_convert( buffer, 22 ) - set for 22 samples
4) Trigger sampling by calling nrfx_saadc_sample()
100 MILLISECONDS later, the saadc_callback is executed.
Do you have example code for how unblocked saadc works? When I execute the following code, it takes 100ms for the saadc_callback to be called! By by calculations it should take only 100 MICRO seconds.
1) Initialize the saadc by calling nrf_drv_saadc_init()... which calls nrfx_saadc_init()
parameters: NULLP, saadc_callback
2) Initialize saadc channel by calling nrf_drv_saadc_channel_init() ... which calls nrfx_saadc_channel_init()
configuration data:
.resistor_p = NRF_SAADC_RESISTOR_DISABLED, \
.resistor_n = NRF_SAADC_RESISTOR_DISABLED, \
.gain = NRF_SAADC_GAIN1_4, \
.reference = NRF_SAADC_REFERENCE_INTERNAL, \
.acq_time = NRF_SAADC_ACQTIME_3US, \
.mode = NRF_SAADC_MODE_SINGLE_ENDED, \
.pin_p = MON_VBOOST, \
.pin_n = NRF_SAADC_INPUT_DISABLED \
3) Start conversions using nrfx_saadc_buffer_convert( buffer, 22 ) - set for 22 samples
4) Trigger sampling by calling nrfx_saadc_sample()
100 MILLISECONDS later, the saadc_callback is executed.
Hello again,
SentinelLighting said:100 MILLISECONDS later, the saadc_callback is executed.
What else is you application doing? What other peripherals and features of the nRF are you utilizing?
Since you are using the CPU to trigger the sampling through the call to nrfx_saadc_sample, you might be interrupted by a higher priority task, such as the SoftDevice or any other interrupt with sufficient priority.
From which context are you calling nrfx_saadc_sample?
SentinelLighting said:Do you have example code for how unblocked saadc works?
The SAADC peripheral example demonstrates this perfectly, since the sampling is triggered by a TIMER instance connected to the TASKS_SAMPLE through the PPI peripheral. I really recommend that you take a look at this example. In the example the CPU is not involved at all in the triggering of each sample, which is the recommended way of doing this both in regards to power consumption and accurately maintaining the sampling period.
Best regards,
Karl
I thought the method I was using set up the DMA to automatically transfer data samples into the buffer? My assumption was this was un-interruptable and the cpu was not involved!? I have BLE running and a 50ms timer. When the 50ms timer starts up it initiates the saadc unblocked mode. The timer may go back to sleep BEFORE the callback function executes. My assumption was this was ok? I assumed the callback would wake up and execute.
SentinelLighting said:I thought the method I was using set up the DMA to automatically transfer data samples into the buffer?
Yes, but you will still need to collect the samples to be transferred by triggering the SAADC to perform sampling.
SentinelLighting said:My assumption was this was un-interruptable and the cpu was not involved!?
Any instruction carried out by the CPU is interruptible unless performed at the highest priority or in a critical region - neither of which is the case here. If the SoftDevice is present it will also control the highest priority levels available to the application, and as such be able to interrupt your application at any time.
SentinelLighting said:I have BLE running and a 50ms timer. When the 50ms timer starts up it initiates the saadc unblocked mode. The timer may go back to sleep BEFORE the callback function executes. My assumption was this was ok? I assumed the callback would wake up and execute.
I am not sure that I have understood what you meant by this. You have a timer that initializes your SAADC in unblocked mode - is this time also connected to the TASKS_SAMPLE task, to trigger sampling of the SAADC?
I urge you to take a look at the SAADC example as it does exactly the functionality it seems you are seeking to achieve. Please see my previous comment's detail of the SAADC examples function.
Best regards,
Karl