Confused about what to do with unused I/O Pins

Thread Starter

ke5nnt

Joined Mar 1, 2009
384
I suppose this question is probably generic to PIC MCUs, but my current project is using the PIC12F629. I'm confused on whether there is a "proper" practice for what to do with extra I/O pins that you don't need.

My project requires GP0 and GP4 to be outputs and GP2/INT to be an input. The datasheet for the device doesn't specify what to do with unused pins, but I notice that the value on reset for the TRISIO register sets them all at inputs by default. Assuming that the unused pins were not tied to anything, wouldn't this leave them as floating inputs? My understanding is that this is a bad thing.

A thread on the microchip website had made mention that
You must NOT leave the pin floating as input. This can make the input circuitry to draw excess current.
Okay, so set the unused pins as outputs and set as 0 in the port register. Sounds easy, except that on the PIC12F629, GP3 is input only. This basically forces a floating input on GP3 unless you actually use it for an input.

So, what would be the optimal solution for what to do with the unused ports? Thanks.
 

JohnInTX

Joined Jun 26, 2012
4,787
Set them to outputs and write '0' to them.

Leave them as inputs and tie to Vdd/GND

Best: Pull them up / down with a 10K -68K resistor. This will keep you from driving into a short or the supply if you config them wrong or the program goes nuts and hammers the TRIS register(s). It also keeps from having unconnected pins which can introduce noise and are more succeptable to ESD when handling the boards (although PICs are pretty tough).

The default as input (or analog input as applicable) to prevent the IO contentions that would happen if they were outputs at power up.

If you have a dedicated input and no space for pullups you can tie it to an output.

What you decide will depend on space, cost , how easy you want it to be to modify IO after building a proto board etc.
 
Last edited:

t06afre

Joined May 11, 2009
5,934
Take a look here http://ww1.microchip.com/downloads/en/devicedoc/01146b_chapter 2.pdf at page 2-4.
Unused Port Pins
If a port pin is unused, it may be left unconnected but configured as an output pin driving to either state (high or low), or it may be configured as an input with an external resistor (about 10 kΩ) pulling it to Vdd or Vss. If configured as an input, only the pin input leakage current will be drawn through the pin (the same current would flow if the pin was connected directly to Vdd or Vss). Both options allow the pin to be used later for either input or output without significant hardware modifications.
 
Top