ADC->ADC_RPR=(uint32_t)buf[0]; // DMA buffer
ADC->ADC_RCR=256;
ADC->ADC_RNPR=(uint32_t)buf[1]; // next DMA buffer
ADC->ADC_RNCR=256;
bufn=obufn=1;
I'm not sure, but it look like the Due is using buffer 0 for writing and reserving buffer 1 as the next buffer to be used.
If it is the case there is 2 buffer in use.
while(obufn==bufn); // wait for buffer to be full
This line should be
while((obufn + 1)%4==bufn); // wait for buffer to be full
Also why start at buffer 1 ??
bufn=obufn=1;
Would be better to start at 0.
bufn=1;
obufn=0;
Not sure if i understood the code properly, i hope someone can tell me more about this.