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.
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
This is where your documentation is confusing, or doesn't give a simple explanation of what the individual functions do! Here are my questions:
1) Are you saying that nrfx_saadc_sample() simply sits and 'spins' until the number of samples are acquired?
2) Are you saying that nrfx_saadc_buffer_convert() enables the DMA to transfer the data?
3) DOZENS of other micros I have used has a simple method to have the ADC connected directly to the DMA and just sample, convert and transfer without multiple steps. Is this process possible with Nordic?
SentinelLighting said:This is where your documentation is confusing, or doesn't give a simple explanation of what the individual functions do!
Please tell me exactly which section or sentences from the documentation that you find confusing, so I may attempt to clear things up.
SentinelLighting said:1) Are you saying that nrfx_saadc_sample() simply sits and 'spins' until the number of samples are acquired?
No, this is not what I am saying.
I think a lot of your confusion would vanish if you took a look at the nrfx_saadc source code instead of making assumptions or guesses at what is happening behind the scenes. As mentioned the nrfx_saadc_sample triggers the TASKS_SAMPLE task, which initiates a sampling. It is not a blocking function, such as nrfx_saadc_convert_sample.
If you want multiple samples you will need to trigger the sample task multiple times, as mentioned in the continuous mode section of the SAADC documentation.
SentinelLighting said:2) Are you saying that nrfx_saadc_buffer_convert() enables the DMA to transfer the data?
This is part of what it does, yes. In essence it is used to provide the SAADC with buffers and make it ready to begin sampling.
An exempt from the nrfx_saadc_buffer_convert API Reference reads:
The SAADC will be ready for sampling and wait for the SAMPLE task. It can be triggered manually by the nrfx_saadc_sample function or by PPI using the NRF_SAADC_TASK_SAMPLE task.
SentinelLighting said:3) DOZENS of other micros I have used has a simple method to have the ADC connected directly to the DMA and just sample, convert and transfer without multiple steps. Is this process possible with Nordic?
I do not know what other micros you are referring to here, but there is indeed a simple way - configuring the SAADC and calling nrfx_saadc_sample or nrfx_saadc_sample_convert every time you would like a sample to be taken. Alternatively, you could also use the nrfx_saadc_sample_convert function if you would like the call to be blocking (waiting for the sampling to complete before moving on with the program). This is, as I have previously advised, not a good way of generating periodic samples because it requires CPU involvement for every sample and it is therefore vulnerable to interruption by higher priority tasks such as the SoftDevice.
The recommended way to produce a series of periodic samples is therefore to connect an event to the TASKS_SAMPLE through PPI, like demonstrated in the SAADC example mentioned earlier. I again urge you to take a look at this example if you have not already.
Best regards,
Karl
You wrote: "If you want multiple samples you will need to trigger the sample task multiple times, as mentioned in the continuous mode section of the SAADC documentation.:
-WHERE does your documentation say this? From what I have read it does not say that.
The documentation implies that if I pass a buffer for 25 readings, and pass the num_samples as 25, like this... nrfx_saadc_buffer_convert(buffer, 25); ... and then call nrfx_saadc_sample() that it will go get 25 samples, transfer them to the buffer and issue the callback when done. Are saying I have to call nrfx_saadc_sample 25 times, waiting in between calls for the adc to convert? That is basically blocking mode!
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.