0

Hello the arduino documentation on the due specifies the pin mapping of the pins.I am making a custom board using the dues schematics and i am running still a bit low on pins. Also some of the special pins offer a better position for traces.

So is it possible digitalWrite()/digitalRead() the specials pins such as:

  • RX (0-3)
  • TX (0-3)
  • SDA (0-1)
  • SCL (0-1)
  • CANRX
  • CANTX
  • LED RX
  • LED TX
  • MISO
  • MOSI
  • SCLK

As for the SPI and i2c lines i will be using them for the original purpose,but i would like to take the opportunity to know anyway.

I do not own a due so unfortunately i can not test it

1

Yes, although you may need to modify the variant files to allow access to them.

Every function on the SAM3X8E is a "multiplexed" function. That is, it shares pins with other functions. For example CANTX0 is an alternative function on pin PA0.

You can find all the alternative function mappings on page 40 of the datasheet.

You may find that many of these pins already have an Arduino pin number assigned to them in the variant file. If that is the case then you can just use it as you would any digital IO pin.

I have included the comments from the variant files here for quick reference:

/*
 * DUE Board pin   |  PORT  | Label
 * ----------------+--------+-------
 *   0             |  PA8   | "RX0"
 *   1             |  PA9   | "TX0"
 *   2       TIOA0 |  PB25  |
 *   3       TIOA7 |  PC28  |
 *   4       NPCS1 |  PA29  |
 *           TIOB6 |  PC26  |
 *   5       TIOA6 |  PC25  |
 *   6       PWML7 |  PC24  |
 *   7       PWML6 |  PC23  |
 *   8       PWML5 |  PC22  |
 *   9       PWML4 |  PC21  |
 *  10       NPCS0 |  PA28  |
 *           TIOB7 |  PC29  |
 *  11       TIOA8 |  PD7   |
 *  12       TIOB8 |  PD8   |
 *  13       TIOB0 |  PB27  | LED AMBER "L"
 *  14       TXD3  |  PD4   | "TX3"
 *  15       RXD3  |  PD5   | "RX3"
 *  16       TXD1  |  PA13  | "TX2"
 *  17       RXD1  |  PA12  | "RX2"
 *  18       TXD0  |  PA11  | "TX1"
 *  19       RXD0  |  PA10  | "RX1"
 *  20             |  PB12  | "SDA"
 *  21             |  PB13  | "SCL"
 *  22             |  PB26  |
 *  23             |  PA14  |
 *  24             |  PA15  |
 *  25             |  PD0   |
 *  26             |  PD1   |
 *  27             |  PD2   |
 *  28             |  PD3   |
 *  29             |  PD6   |
 *  30             |  PD9   |
 *  31             |  PA7   |
 *  32             |  PD10  |
 *  33             |  PC1   |
 *  34             |  PC2   |
 *  35             |  PC3   |
 *  36             |  PC4   |
 *  37             |  PC5   |
 *  38             |  PC6   |
 *  39             |  PC7   |
 *  40             |  PC8   |
 *  41             |  PC9   |
 *  42             |  PA19  |
 *  43             |  PA20  |
 *  44             |  PC19  |
 *  45             |  PC18  |
 *  46             |  PC17  |
 *  47             |  PC16  |
 *  48             |  PC15  |
 *  49             |  PC14  |
 *  50             |  PC13  |
 *  51             |  PC12  |
 *  52       NPCS2 |  PB21  |
 *  53             |  PB14  |
 *  54             |  PA16  | "A0"
 *  55             |  PA24  | "A1"
 *  56             |  PA23  | "A2"
 *  57             |  PA22  | "A3"
 *  58       TIOB2 |  PA6   | "A4"
 *  69             |  PA4   | "A5"
 *  60       TIOB1 |  PA3   | "A6"
 *  61       TIOA1 |  PA2   | "A7"
 *  62             |  PB17  | "A8"
 *  63             |  PB18  | "A9"
 *  64             |  PB19  | "A10"
 *  65             |  PB20  | "A11"
 *  66             |  PB15  | "DAC0"
 *  67             |  PB16  | "DAC1"
 *  68             |  PA1   | "CANRX"
 *  69             |  PA0   | "CANTX"
 *  70             |  PA17  | "SDA1"
 *  71             |  PA18  | "SCL1"
 *  72             |  PC30  | LED AMBER "RX"
 *  73             |  PA21  | LED AMBER "TX"
 *  74       MISO  |  PA25  |
 *  75       MOSI  |  PA26  |
 *  76       SCLK  |  PA27  |
 *  77       NPCS0 |  PA28  |
 *  78       NPCS3 |  PB23  | unconnected!
8
  • Well PA0 is kinda okay since it does not share with other pins. Digital 10 and 4 are have shared pins(PA29), how does that work ? if write high to D10 and LOW to D4, how will that work ? wont both of them short out? – Jack Jan 8 '20 at 12:56
  • Also if i access the pins via register manipulation do i still need to modify the variant files? They do have an arduino number (69 for CANTX) so i was thinking it should theoretically work, just needing confirmation – Jack Jan 8 '20 at 13:11
  • 1
    D10 is PA28 isn't it? If there is a number assigned in the variant files then you can just use that as you would for any other digital pin. If you use port manipulation then the variant files don't come into play at all. – Majenko Jan 8 '20 at 13:13
  • If you look at the link in the question thats from the official arduino page, pin 4 connected to both PA29 and PC26 and pin 10 connected to both PA28 and PC29 . – Jack Jan 8 '20 at 13:18
  • 1
    @Jack Done and done – Majenko Jan 8 '20 at 13:48
0

As far as I know you can use them as GPIO too (I know for sure for Arduino Uno/Mega etc., I know for STM32, I would be very surprised if it's not possible for Arduino Due.

Other solutions are using shift registers like:

  • 74HC595: For adding upto 32 outputs using SPI
  • 74HC565: For adding upto 32 inputs using SPI

Or you can use GPIO extenders using either SPI or I2C.

4
  • 1
    Yes my worst case scenario is using a GPIO extender MCP23S17 – Jack Jan 8 '20 at 12:16
  • I can imagine, the shift registers are easier (enough documentation available for the Arduino Uno/Mega, probably will work on Due as well). Why don't you try to write to a pin directly, or you don't have a Due at hand? – Michel Keijzers Jan 8 '20 at 12:24
  • 1
    I dont have a due at hand unfortunately, there are no store that i could find that sells them, there are online stores buy they charge a pricey 30$ for shipping. – Jack Jan 8 '20 at 13:10
  • You can try aliexpress but than you have to wait very long. – Michel Keijzers Jan 8 '20 at 15:10

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.