The setup : nrf 52840 , NCS 1.9.1 , The SAADC is configured in advanced mode with 1 single end channel and double buffered with size of 16 (32bytes). RTC is configured to tick at 128 Hz. (pre scaler = 255). This tick event is connected to SAMPLE task via a PPI channel.
When RTC is enabled, it starts ticking and PPI triggers sample task, SAADC samples and stores in the buffer, calls event handler when buffer is filled.
This continues till RTC is disabled. which is what the intended operation.
Everything is good so far, until I added another channel for sampling.
And ran into the problem something like the one discussed in this ticket . Followed the first solution mentioned there and ran into another one.
This time it is with redundant data on the third buffer.
The third buffer is giving the same data as the first buffer. The driver is given two buffers before enabling the RTC and after each NRFX_SAADC_EVT_DONE event, another buffer is requested by calling event handler. (notice that the SAADC END event is connected to SAADC START task via PPI so i gave start_on_end as false in the saadc configuration.)
The first buffer given from event handler happens to be the third one for driver, this buffer is not over written with new samples. I have changed the static buffers to dynamic buffers, altered between 3 different buffer but no change in this behavior.
After some investigation into the driver and SDK's example of the similar implementation,
noticed that a new buffer is set right when NRFX_SAADC_EVT_DONE is received. In order to do the same with NCS i made these two changes in the NCS saadc driver.
and set the buffer right when NRFX_SAADC_EVT_DONE is received in my code just like in SDK example.
This solved the all my problems with the code for now. And the only remaining question is .. Does this change affect any part of the driver or performance of the SAADC or not.?? Can I rely on this ??
Or is there any other way to do this.??
The saadc driver seems to be updated in the later versions but the only change at this point in code i see is that saadc_trigger called first by checking start_on_end flag before calling the event handler with NRFX_SAADC_EVT_DONE event...