Arduino Due ADC register access

Hi,
I’m working on Arduino Due oscilloscope.
This part of code is used in several Arduino Uno scope projects, original code is at closed thread: Faster analog read?
Uno compiles ok, but when compiling code for Due I got errors about ADCSRA, ADPS2, _BV, ADPS1, ADPS0 not declared in this scope.

//char foo;
// # include <Arduino.h>
// High speed ADC code
// From: http://forum.arduino.cc/index.php?PHPSESSID=e21f9a71b887039092c91a516f9b0f36&topic=6549.15
#define FASTADC 1
// defines for setting and clearing register bits
#ifndef cbi
   #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif

#ifndef sbi
   #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

void setup() { 
  #if FASTADC
    // set prescale to 16
    sbi(ADCSRA,ADPS2) ; // set register A
    cbi(ADCSRA,ADPS1) ;
    cbi(ADCSRA,ADPS0) ;
  #endif
  delay(100);
}

void loop() {
} //SAM3A manual LDR Load Register,STR Store Register, Syntax: ADR{cond} Rd, label

Found reused code at:
Arduino-fio-lcd-oscilloscope
Registers and commands (ADC Setting Register A) explained in details here:

Arduino DUE is based on completely different uCPU architecture, it doesn't have ADCSRA etc. You may get overview of all registers names out of data sheet, from atmel.com SAM3X This library has sampling subroutine, you want to study.

Thanks for link, will check.

Checked SAM3A and 328 manuals.

ATmega328: "ADC prescaler bits determine the division factor between system clock frequency and the input clock to the ADC", and manual lists ADPS2 ADPS1 ADPS0, and settings 2,4,8,16,32,64 and 128. System clock for 328 is 16Mhz. "analogRead() will just return faster if set prescaler" Above code writes to registers 1 0 0 which corresponds to prescaler 16.

SAM3A manual lists SUT0 to SUT960. So equivalent code would target SUT0 to SUT960.

SAM3A manual lists SUT0 to SUT960. So equivalent code would target SUT0 to SUT960.

??? Have no idea what you are talking

Found it. Thanks.

http://frenki.net/2013/10/fast-analogread-with-arduino-due/

Thanks to stimmer and toppic I wrote alternate analogReadFADC function.
Please check is this coding ok, is result the same as with default analogRead.

void setup() {

//boot settings for ADC device
 ADC->ADC_MR |= 0x80; // these lines set free running mode on adc 7 and adc 6 (pin A0 and A1 - see Due Pinout Diagram thread)
 ADC->ADC_CR=2;
 ADC->ADC_CHER=0xC0; // this is (1<<7) | (1<<6) for adc 7 and adc 6                                     
}

int analogReadFADC(Pin){  
   int a0;
   while((ADC->ADC_ISR & 0xC0)!=0xC0);// wait for two conversions (pin A0[7]  and A1[6])
   a0=ADC->ADC_CDR[Pin]; // read data on A0, pin 7
   return a0;
 }
}

void loop() {
 int a0;
 a0=analogReadFADC(7); / is this result same as a0=analogread(7)?
}

|500x375

Check it out.

Thanks Magician, but I was wrong. Further reading on registers reviled details of above code to me. What I needed is sampling of basic 50 Hz, 2nd, 3rd, 4th, and 5th harmonics, all less than 1kHz so default ADC sampling rate will suffice.