Mapping Arduino pins to SAMD21 GPIO Port/Pin #s?

I'm using a SAMD21 XPRO board with the Arduino bootloader -- it all seems to be working. (But let me know if this topic is posted in the wrong forum!)

I'm about to bring up a display board with driver code written for Arduino. My problem: when the Arduino code says something like pinMode(10, OUTPUT);, how do I discover what SAMD21 GPIO Port / Pin number that corresponds to?

In short: is there a secret decoder ring to map between Arduino-style pin numbers and"native" SAMD21 Port / Pin numbers?

I think I just answered my own question, but please warn me if I'm confused.

The variant.cpp file in the Atmel University France · GitHub git repository appears to have an array of pin descriptors.

If I'm reading that correctly, (for example), Arduino pin 2 maps to SAMD21 PB30, which is, in fact, the LED port on the SAMD21 XPRO board:

 * | 2          | N/A              |  PB30  | LED0            | EXTINT[14] SERCOM5/PAD[0]                TCC0/WO[0] TCC1/WO[2]

However, I'm not clear on why demo software that blinks the LED refers to this as PIN_LED_13:

  // initialize digital pin 13 as an output.
  pinMode(PIN_LED_13, OUTPUT);

I see that PIN_LED_13 is defined as 2, so it does map to the LED. But why is it named PIN_LED_13? Is that some historical artifact?

the pin mapping is in the variant files of the board you selected. the files are on your computer. on GitHub they are here if you use the Arduino SAMD boards support package..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.