Hi Stee,
One thing to notice in your code is that in your loop, you are writing a buffer's worth of data. You are not writing 1 data value but you are writing 1024 points, I believe. On the input, I also notice that you are not reading 1 point at a time but are reading 1024 points at a time as well. Based on the timing of your device, you are writing a value and then you are reading the value right away. However, since you sent the data to be written in 1 loop iteration, it is not likely that you will be reading in that exact buffer of data that you just wrote. It is more likely that you are reading in the buffer that you wrote out the previous iteration. This doesn't mean that your data isn't perfectly synchronized though. You will hav
e too test it by writing a finite number of points, let's say 10,000 points, and then try reading in 10,000 points as well. Overall, you will read the exact number of points and they will correspond to the same points you wrote and in the same order.
The key in this case is that you start the process off by writing X amount of data (we'll call it x1). In your loop, you write the next X amount of data x2. However, at this point, if you are reading the same number as you wrote out the first time, you will be reading x1's data. So you will be off by 1 write cycle. It also looks like you initially write 4096 points in the first place. This means your data read will be off by 5 iterations.
Anyway, I hope I understood your code correctly. That is what I believe you are seeing though. Have a good day.
Ron