Go Down

Topic: Problem declared as input or output port Arduino Due (Read 99 times) previous topic - next topic

SergioMecatronic

Hi ! Can you help me with the code please?
The problem is that when I compile the program mark misstatement of the ports would like to know the instruction to declare ports on the arduino due , could someone do me a favor and pass this program due to the language of arduino .
Enclosed is a copy below:


Code: [Select]
byte  sensor;
byte lectura;


byte secuencia1 = B00000110;
byte secuencia2 = B00100100;
byte secuencia3 = B00100001;
byte secuencia4 = B00001001;
byte secuencia5 = B00011000;
byte secuencia6 = B00010010;
int a = 0;

void setup() {
DDRL = B11111111; // declare L port bit as outputs
DDRC = B11111000; // declare C port bits as input

}

void loop() {
 
  sensor = PINC;
  digitalWrite(sensor, BIN);
  lectura = sensor;   
   
 
  if( lectura == B00000101 ){
     PORTL = secuencia1;
     delay(a);
  }
 
  if( lectura == B00000100 ){
    PORTL = secuencia2;
    delay(a);
  }
 
  if( lectura == B00000110 ){
    PORTL = secuencia3;
    delay(a);
  }

  if( lectura == B00000010 ){
    PORTL = secuencia4;
    delay(a);
  }
 
  if( lectura == B00000011 ){
    PORTL = secuencia5;
    delay(a);
  }
 
  if( lectura == B00000001 ){
    PORTL = secuencia6;
    delay(a);
  }
 
  }



This is the error that makes me:

Code: [Select]
Arduino: 1.5.8 (Windows 8), Placa:"Arduino Due (Programming Port)"

sketch_oct24a.ino: In function 'void setup()':
sketch_oct24a.ino:14:1: error: 'DDRL' was not declared in this scope
sketch_oct24a.ino:15:1: error: 'DDRC' was not declared in this scope
sketch_oct24a.ino: In function 'void loop()':
sketch_oct24a.ino:21:12: error: 'PINC' was not declared in this scope
sketch_oct24a.ino:27:6: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:32:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:37:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:42:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:47:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:52:5: error: 'PORTL' was not declared in this scope
Error de compilaciĆ³n

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.






rmetzner49

Not sure why you want to steer around the digital.Read and digital.Write functions.  Your compiler problem is you are missing the definitions of the ports you are trying to manipulate.  Have a look at your Arduino Installation:  Program_Files86\Arduino\hardware\arduino\sam\variants\arduino_due.  There you will find variants.cpp and variants.h showing how to use the ports.  You will have to include that file if this is how you want to do your reads and writes.

PCWorxLA

Hi ! Can you help me with the code please?
The problem is that when I compile the program mark misstatement of the ports would like to know the instruction to declare ports on the arduino due , could someone do me a favor and pass this program due to the language of arduino .
Enclosed is a copy below:


Code: [Select]
void setup() {
DDRL = B11111111; // declare L port bit as outputs
DDRC = B11111000; // declare C port bits as input

}

void loop() {
...
 
}



This is the error that makes me:

Code: [Select]
Arduino: 1.5.8 (Windows 8), Placa:"Arduino Due (Programming Port)"

sketch_oct24a.ino: In function 'void setup()':
sketch_oct24a.ino:14:1: error: 'DDRL' was not declared in this scope
sketch_oct24a.ino:15:1: error: 'DDRC' was not declared in this scope
sketch_oct24a.ino: In function 'void loop()':
sketch_oct24a.ino:21:12: error: 'PINC' was not declared in this scope
sketch_oct24a.ino:27:6: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:32:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:37:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:42:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:47:5: error: 'PORTL' was not declared in this scope
sketch_oct24a.ino:52:5: error: 'PORTL' was not declared in this scope
Error de compilaciĆ³n

Your basic mistake with the code (as posted) is the fact that you nowhere actually declare the variables that produce those "was not declared in this scope" error messages...

Ralf

Palliser

DDRx, PORTx and PINx are AVR registers. They do not work with Due (SAM). It's about to port your code from the platform AVR to SAM which is not a straightforward task.


PCWorxLA

#4
Oct 31, 2014, 11:08 pm Last Edit: Oct 31, 2014, 11:08 pm by PCWorxLA
DDRx, PORTx and PINx are AVR registers. They do not work with Due (SAM). It's about to port your code from the platform AVR to SAM which is not a straightforward task.


The code (as posted) won't compile for an AVR based board either, you get the same error messages...
Code: [Select]
Arduino: 1.5.8 (Windows 8), Board: "Arduino Leonardo"

sketch_oct31a.ino: In function 'void setup()':
sketch_oct31a.ino:14:1: error: 'DDRL' was not declared in this scope
sketch_oct31a.ino: In function 'void loop()':
sketch_oct31a.ino:27:6: error: 'PORTL' was not declared in this scope
sketch_oct31a.ino:32:5: error: 'PORTL' was not declared in this scope
sketch_oct31a.ino:37:5: error: 'PORTL' was not declared in this scope
sketch_oct31a.ino:42:5: error: 'PORTL' was not declared in this scope
sketch_oct31a.ino:47:5: error: 'PORTL' was not declared in this scope
sketch_oct31a.ino:52:5: error: 'PORTL' was not declared in this scope
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

Ralf

Go Up