Hmm... I opened the plot again in matlab and zoomed in and you are right there are 3 samples missing, I certainly will be more observant of that kind of thing after this. I did not notice that and I was not near to do so ether.
I use a two dimensonal array(2x2048) for the DMA(its a PDC channel to be correct) and a ADC handler to switch between them when the current one has been filled up, from a function I can request(from matlab) a number of buffer to be transfered. I use only one for the moment so on request I use a for loop to go through one of the two buffers(2048 values in each) and in each 'for' iteration I do:
Serial.write(inp[idx] >> 8); // uint16_t inp[2][2048].
Serial.write(inp[idx] & 0xff)
and then in matlab(after appropiate setup of serial port):
ans = s.bytesavailable; // check how many bytes is in the receive buffer.
x = fread(s, ans); // reads those bytes into x.
msb = x(1:2:end); // stores the first byte of x, and every other from there.
lsb = x(2:2:end); // the same only from the second byte to split x in two.
data = ((msb .* 256) + lsb); // creating data containing all the original ADC results.
plot(data) // plot those results.
I don't see how the problem would be of my handling of the DMA(after the DMA buffer has been filled) I will try to do it without DMA once and see if that solves it, I could show how the PDC is set up but it would be better for another forum section since it would be purely SAM3X programming...
I've tested this on two different arduino Due so I think that's proved that it is a flaw in how I use it and not some flaw in the µC itself, I'll get back as soon as I have tried this without PDA/DMA. By the way, I intended to use the ADC PDC to store the results and then the UART PDC to send them to the PC but I have not gotten it working jet.