1

It is possible to access the Physical Pin 93, Pin PC11 on ATSAM3X8E in Arduino Due from the Arduino IDE?

I am programming a Barebone ATSAM3X8E, and it do not seems to be allocated by Arduino Due nor by ATSAM3X8E for any other purpose than the PC Port.

enter image description here enter image description here enter image description here

1
1

Modifying/Making a variant

If you wanted to do it in an Arduino-like way it would require editing the Arduino Due variant.cpp or copying the making your own variant, say from a copy of the Due, and editing the extern const PinDescription g_APinDescription[] array to include an entry that matches for PC11.

Example changes

As an experiment I made the following changes to files in the packages/arduino/hardware/sam/1.6.12/variants/arduino_due_x under the arduino15 directory.

In variant.cpp, an entry for in the g_APinDescription array is insert an index number 79, between the existing two entries (shown for context):

  { PIOB, PIO_PB23B_SPI0_NPCS3,ID_PIOB,PIO_PERIPH_B,PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, // NPCS3
  // Addition line here VVVV (this is the line for PC12, copied with PIO_PC12 changed to PIO_PC11
  { PIOC, PIO_PC11,          ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL,                  NO_ADC, NO_ADC, NOT_ON_PWM,  NOT_ON_TIMER }, //
  // 79 .. 84 - "All pins" masks

  // 79 - TWI0 all pins
  { PIOA, PIO_PA17A_TWD0|PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },

This is a copy of the entry for PC12, with PIO_PC12 changed to PIO_PC11.

In variant.h, PINS_COUNT changes to 80u, because we've inserted the pin:

#define PINS_COUNT           (80u)

and later in the file the pin number associate with CAN are bumped up by one also because they're all numbered after the point of insertion:

/*
 * Complementary CAN pins
 */
static const uint8_t CAN1RX = 89;
static const uint8_t CAN1TX = 90;

// CAN0
#define PINS_CAN0            (91u)
// CAN1
#define PINS_CAN1            (92u)

I programmed a sketch the blinks PC11 by way of digitalWrite(79, state); and carefully placed a logic probe on the the unrouted pin on the Due board, and it "blinks" just fine. That's as far as I've tested.

Direct control

Alternately you could control the pin in your code manually, doing what digitalWrite or digitalRead would normally do. In other words, you could read the description of something like digitalWrite here and substitute all of the references that it would have gotten from g_APinDescription with hard-coded values.

6
  • 1
    If I get a chance I will try altering the variant here. It looks like the new pin would have to be inserted before the PINS_COUNT index, which would need to be made larger by one. And then PINS_COUNT and a few other named values for pins would have to change to reflect all their indices increasing by one. – timemage Jun 9 at 16:42
  • I made the six line changes indicated, for some reason the 93 physical pin, PC11, in our sketch at 79, it stays at 3.3V. I will keep trying – Brethlosze Jun 9 at 18:54
  • You remember to pinMode(79, OUTPUT); ? – timemage Jun 9 at 18:56
  • Yes... as all other pins. As reference, it is the 93 physical pin in ATSAM3X8E, it is located close to the A0 connector, in the Arduino Due board. – Brethlosze Jun 9 at 18:56
  • I gather from the that and the update that you're concern we're not talking about the same pin, but I'm pretty sure we are. Here is the contact I'm making to probe. – timemage Jun 9 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.