Background: I'm looking at writing a library to drive an LED matrix panel (one of these:http://www.adafruit.com/product/607) from my newly acquired Arduino Due. My background is C++ programming, not electronics.

I'm planning to experiment with various optimisations of the code for memory and speed, but one constant is that I would like to be able to send the data to the matrix with single memory writes to port registers without having to use masking operations to leave certain bits unaffected. As I need to send 6 bits of data with a clock signal, I figured this could be easy with an 8 bit write to one byte of a port register. The 8th bit/pin could be used as the latch or some other used line.

Looking at the nice pinout diagram that someone has kindly put together (http://forum.arduino.cc/index.php/topic,132130.0.html), I was pretty shocked to discover that my plans weren't going to be as easy as I would have liked. There are only two circumstances where there are whole bytes of port registers that connect to digital pins (Port A byte 1 and Port D byte 0). All other bytes have "holes" in them, for example Port C byte 0 has no connection for bit 0, but has bits 1-7;

While two complete bytes is enough (I actually only need to use 13 pins to control the display, plus ground connections), the pins of the available two are spread out in a way that would make it a little awkward for me to make a stripboard shield as I intended due to the pins on the Arduino boards not being evenly spaced (why is that?) and I'm guessing that since most of the digital pins in Port A byte 1 are used for communication pins (including RX0 and TX0) I would lose my ability to print to the debug log. As a result, I've ruled out using those port registers.

That leaves me with bytes 0 and 1 of Port C. There are just enough pins available with those bytes and they are grouped nicely on the double connector at the bottom of the board (Digital pins 33-40 and 48-51), however some bits in those bytes are not mapped to Arduino IO pins.

Would it be bad if I were to write to bits of a port register that do not have Arduino IO pins assigned to them? Would the answer depend on whether I had set those bits to be inputs or outputs using the Output Write Enable Registers? I'm assuming that these bits are used for IO pins on the SAM3X8E chip but just not made available to the Arduino boards.

1 Answer 1


If the pins have no connection to the outside world (i.e., they don't have any actual pin associated with them on the SAM3X chip) then writing to the PORT (or indeed any other register associated with them) will have no effect whatsoever.

If they have a pin but that pin is not connected to anything, then there will be little effect. There may be slightly increase current draw as the pin switches on/off, or you enable/disable the internal pullup resistor, but that's all.

If the pin exists and is connected to something on the board - maybe a button or LED, then you will basically be providing an output to that item. If it's an LED it will flash. However, if it's a button, and you provide an output opposite of its active state (i.e., provide a HIGH when it normally connects to ground when you press it) and that button lacks any current limiting resistance, then you could risk burning out that IO pin if the button gets pressed.

If the pin just goes straight to a header, then as long as nothing gets connected to that header then there will be no effect other than as detailed in the "pin present on the chip but not connected".

  • Thanks for the very concise info. Do you known how I can find out if the bits of a PORT register do relate to pins on the SAM3X chip and then if those pins are used on the Arduino board? Apr 25, 2015 at 5:37
  • Read the datasheet and the schematic.
    – Majenko
    Apr 25, 2015 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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