How to use all Physical Pins on the Arduino Due?

Hi!

I built a custom Board with the Sam3X8E Chip. Im using the direct Port manipulation since it is quite fast, also not all Physical Pins are mapped to the Arduino environement.

REG_PIOB_SODR = 0x1 << 27;
REG_PIOB_CODR = 0x1 << 27;

But how can I use the extended Pins with some Arduino functions like, for example, AttachInterrupt?

attachInterrupt(PIN_PIOB1 , readTacho1, RISING);

Of course it is not working since PIN_PIOB1 is not the correct name: Analog_Board.ino:33: error: 'PIN_PIOB1' was not declared in this scope

How can I use all the Pins within my sketches without changing the Arduino Pin mapping files?

Thanks!

Hello tsaG,

variant.h defines some pins that you can use directly with Arduino functions like LED pin 13 which is PIN_LED_13 or PIN_LED in variant.h (see lines 75 and 78). Thus, you can use this pin for example as follows:

void setup() {
  pinMode(PIN_LED, OUTPUT);
}

void loop() {
  digitalWrite(PIN_LED, HIGH);
  delay(1000);
  digitalWrite(PIN_LED, LOW);
  delay(1000);
}

If you want to use pin 53 (not defined in variant.h) You have to add in variant.h the following line

#define PIN_LED_53 (53u)

and now you can use pin 53 with Arduino function.

I hope this help. Best regards,

p