Go Down

Topic: Arduino DUE ADC serial streaming behave differently to Windows and Linux (Read 1 time) previous topic - next topic


Hi all,

I want to use Arduino DUE streaming two ADC channels (A0 and A1) to raspberry pi and make the raspberry pi log and store the data.
The ADC output resolution is 16 bit with around 30 KHz. The data is streaming out through USB virtual serial port /dev/ttyACM0.

The weird problem I have now is when I testing in Windows machine and log with putty, every thing work beautifully as I expect.

However, when I testing in the raspberry pi and log with putty, the data is just go cray from time to time and not stable.
I also tested in other Linux machine like ubuntu, the data is flawed like the pi.
So, I am very confused why this difference happened.
Since the code in Arduino is never changed during all the test, so the problem is from Linux not Arduino?

There are attachments of my test results, the A0 is loging 1kHz (0.5v to 2.5v ) sin wave and A1 is loging constant 3.3v.



For anyone what to further look into this problem, this is the code I am using modified from stimmer's code


volatile int bufn,obufn;
uint16_t buf[4][256];   

void ADC_Handler(){   
 int f=ADC->ADC_ISR;
 if (f&(1<<27)){

void setup(){
 adc_init(ADC, SystemCoreClock, ADC_FREQ_MIN/2, ADC_STARTUP_NORM);
 ADC->ADC_MR |=0x80;

 ADC->ADC_MR |=0x80000000;   



void loop(){
 SerialUSB.write((uint8_t *)buf[obufn],512);

Go Up