Skip to content

Example of FAST ADC does not work for Arduino Due #1137

@jglodo

Description

@jglodo

Hi,
I tried to compile a simple code included at the end of this text with the board set to Arduino DUE and I received the following errors:

sketch_nov26a.ino: In function 'void setup()':
sketch_nov26a:16: error: 'ADCSRA' was not declared in this scope
sketch_nov26a:16: error: '_SFR_BYTE' was not declared in this scope
sketch_nov26a:16: error: 'ADPS2' was not declared in this scope
sketch_nov26a:16: error: '_BV' was not declared in this scope
sketch_nov26a:17: error: 'ADPS1' was not declared in this scope
sketch_nov26a:18: error: 'ADPS0' was not declared in this scope

If I select the Arduino UNO board, there is no problem. I tried to look around for a solution but
so far I have not been able to locate any, and unfortunately I do not have enough experience to solve it.
If it helps, it seems like <avr/io.h> is missing for DUE. #import <avr/io.h> works fine for UNO.

Regards,
Jarek

================= Example ====================

define FASTADC 1

ifndef cbi

define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))

endif

ifndef sbi

define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

endif

int value=0;

void setup()
{
Serial.begin(9600) ;

if FASTADC

sbi(ADCSRA,ADPS2) ;
cbi(ADCSRA,ADPS1) ;
cbi(ADCSRA,ADPS0) ;

endif

}

void loop()
{
for (int i=0;i<100;i++) value = analogRead(0);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions