Arduino Due Direct port Manipulation

Hello guys,

I am trying to use Arduino Due with an external ADC. That means that I have 16 bit word to be read from the ADC via 16 pins on Arduino Due. So there is a strong need of doing this in one operation, where I will read the PORT input register with one atomic read. To save the states of the 16bit input pins. :frowning:

If someone could could explain me the way to solve this would be of great appreciation. I have written a function to do the above mentioned task for AVR ATmega-644P microprocessor, please see the code below, just for gaining better overview of my issue.

static inline void getDataADC(void){

    while((SAMPLE_ADC_CONTROL_PIN & (1 << DATA_READY_ADC)))
          { } // waiting time for DRDY to transition from HIGH >> LOW
            ADC_lowbyte = SAMPLE_ADC_LOW_PIN;
            ADC_highbyte = SAMPLE_ADC_HIGH_PIN;
            ADC_data = ADC_lowbyte | (ADC_highbyte << 8);// Bitwise OR-ing to get low-byte and high-byte
}

any advise would be of high appreciation
David

PIOA, for example, should give you the 16 parallel pins you need to read in a single read with PIOA->PIO_PDSR register.

There are numerous example sketches of GPIO direct reading in the DUE sub forum.

Thanks for the information, what is also of interest, is it possible to connect 5 Volt signal to the SAM3X pins? are they 5 Volts tolerant