What pins should NOT be used for GPIO

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was thinking about a new project that could possibly use a ton of pins on an ATMega.  I recalled that you should not use the reset pin as GPIO as discussed here:

https://www.avrfreaks.net/forum/how-use-reset-pin-pc6-atmega8-normal-io-port

I will probably be using an external crystal so I can't use the XTAL pins.  Outside of these, are there any other pins that I should avoid using for a project?

Last Edited: Wed. Jul 17, 2019 - 06:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Depending on which AVR your wanting to use, if it has a JTAG debug interface, you will want to avoid using the 4 jtag pins!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I once had a board in design that could have used that one more I/O pin that the RESET signal lives upon.  I thought about it for about thirty seconds, then spent several hours hitting myself for even considering it.  Never went there again.

 

Note that an external OSCILLATOR (not just an Xtal) only needs one pin.

 

As I'm sure you'll hear many times more - If you need a ton of pins, get an AVR that comes with a ton of pins.  More difficult to solder down, perhaps.  Less hassle?  Definitely.  And if you're really in need of pins, you can use port expanders like an MCP23S17 (or something like that - I once calculated you could use lots of those to get no less than 250,000 pinouts (yeah, two hundred and fifty thousand pins) from a 20-pin AVR).  S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

What you need to watch out for is the fact that many (standard AVR/Tiny) peripherals (UART, TWI, SPI, and on and on) require the use of specific pins for input and output. So, map out which of these you need to use and exclude them.

 

You sometimes have a few more choices with PWM outputs as there can be more than one compare unit per timer.

 

But, the big lesson here is to decide which of the hardware IO pins you need to use, then exclude those from your consideration.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ton of pins

That's a rather loose specification!

 

Perhaps you could be just a little bit more specific!

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

If you need a ton of pins, get an AVR that comes with a ton of pins.  [or] use port expanders like an MCP23S17

Or use multiple AVRs with some sort of comm link between them.  Newer AVRs seem to be about he same price as port expanders.  (AFAIK, the MCP port expanders are just PICs with pre-burned code...)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

AFAIK, the MCP port expanders are just PICs with pre-burned code...)

No wonder I've been burned by their errata! surprise

 

ton of pins

That's a rather loose specification!

 

Any good arcade will have a ton of them cheeky

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for your answers, everyone.  Actually the project I am thinking of is a port expander in it's own right.  I was thinking of something simple like a 2 dimensional grid using each pin once or perhaps twice.  If I use an ATMega 328 and exclude the Reset, MISO, MOSI, SCK, and crystal pins, that leaves me with 17 pins.  If i build a 2 dimensional grid where I only use each pin once I can have 72 buttons (which may be enough).  If I build a grid using each pin twice I can have 289 buttons (which will be more than enough). 

 

What I find interesting is something that Scroungre said.  The limit of my inputs is 2^n where n is the number of pins I can use on the AVR, in this case 131,072 buttons.  That's so many buttons that the code for all of them won't fit on the AVR.

 

BTW, what is is called when you build an array like I am describing?  I want to call it a multiplexer but I don't think that's correct.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is no numerical limit, you can devise a schem for any number of I/O.  However, the speed of these expanded lines may be quite slow...you need to consider what you will use them for.  PWMing a  foot warmer heater (toohot,toocold)...speed not essential....PWMing an LED brignthness...speed more important....generating stepper motor pulse--speed even more critical!  

 

You probably want a generic solution to provide a mix of "faster" expanded I/O  & slower expanded I/O, to handle most situations.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yungoe wrote:
If i build a 2 dimensional grid where I only use each pin once I can have 72 buttons (which may be enough).

TCA8418 I2C Controlled Keypad Scan IC With Integrated ESD Protection | TI.com

...

  • Supports 80 Buttons With Use of 18 GPIOs
  • Supports QWERTY Keypad Operation Plus GPIO Expansion

...

An ASIC like TCA8418 may or may not be a fit; a cPLD may be a better fit.

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Another reason to leave yourself spare pins is that someday you may very well realize you want to expand the device functionality.  It will mean laying out a new PCB, but if you picked an AVR that had spare pins to begin with, you may not need to migrate the software to a new device.

 

And in the meantime, bring out a few spare pins to pads that you can hook a scope to, for help in debugging.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kk6gm wrote:
And in the meantime, bring out a few spare pins to pads that you can hook a scope to, for help in debugging.
If possible a spare port plus an optional "clock" pin to a logic analyzer.

If one can afford a Saleae logic analyzer :

Saleae Cart - Logic-to-2x4 Header (Gen 2) via Saleae Cart - Accessories

 

MICTOR for higher speed devices (AVR32 UC3, fast arm like SAM V70 and etc)

PIC32 and MPLAB REAL ICE have a few ways to connect; am guessing that the replacement for MPLAB REAL ICE is MPLAB ICD 4 (both have an FPGA and external RAM)

MPLAB REAL ICE In-Circuit Emulator

...

Not recommended for new designs and no new device support will be added to it as of June 1, 2019. For new designs, please consider the MPLAB ICD 4 (DV164045).

...

ICD 4 Block Diagram - Developer Help

 

edit : corrected URL

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Thu. Jul 18, 2019 - 07:04 PM