AnsweredAssumed Answered

IIO contiguous sample accumulation (not working for me)

Question asked by rgetz Employee on Feb 16, 2017
Latest reply on Feb 24, 2017 by epiq-meaghan

Someone asked by email:


We are trying to accumulate a large contiguous buffer of samples from either the AD9361 or AD9371 radio using IIO and are detecting discontinuities in the sample data without overflows (regardless of sample rate used).  Our hope is that you'll be able to provide some recommendations on how to accumulate large contiguous blocks of samples such that we can guarantee the continuity from buffer to buffer. 


With our current implementation, we create a single IIO buffer with iio_device_create_buffer(). We then accumulate multiple buffers worth of samples by repeatedly calling iio_buffer_refill(), and copy the sample data from the IIO buffer to our sample buffer (via memcpy()). Then, once we've accumulated the number of buffers requested, we check the overflow detection at the by reading register 0x80000088 and checking the lower 2 bits for the overflow condition. (per the example at: libiio/iio_adi_xflow_check.c at master · analogdevicesinc/libiio · GitHub  ). Finally, we write our sample buffer to a file for post processing.

Plotting the file gives us something like the attached (which just shows a sine wave that is not contiguous).

capture showing discontiguous data

We had thought that if an overflow was not detected, that the sample data from one IIO buffer to the next would be contiguous but this does not appear to be the case based on our current implementation.  Is there a way to detect discontinuity or do you have any recommendation to ensure continuity across buffers?  Should we be using a different method to accumulate the sample data?


We've ran this both with the ADALM-PLUTO radio (9361-based) and the Mykonos eval board (9371-based) and always detect a discontinuity between buffers.