Are the ports all the same?

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

Forgive the possibly very stupid question, but I've been wondering about this for a while. Is there any specific difference between the different general input/output ports available on AVRs, such as PORTB, PORTC and so forth?
The data sheets of the ones I've played with (tiny45, tiny2313, mega8) don't really say much about it.
Is the difference only in the alternative pin functions such as timer overflows, TWI communication lines and so on?
And just for the sake of asking it: when you have no specific needs for alternative functions and you have more than one port available (that is, no tiny45 or similar ones!), which ports do you use? :)
I tend to use PORTB/PORTD, not really caring for PORTC -- but if I were asked why, I wouldn't really be able to come up with a reasonable answer.

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

I expect that you choose your PORT the same way as anyone else.

Is it handy to connect to ?
Are the pins in a handy order ?

AFAIK, if you do not want the Analog port, it will use exactly the same drive circuitry as any other digital port.

David.

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

Some AVRs have different port/pin drive/sink capabilities than the common ones, but I don't recall which right off the top of my head.

Smiley

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

If there is a difference in how the PORT/PIN functions as a GPIO (general purpose I/O) it will be stated in the data sheet.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Well, there may be differences in your application if you plan to source/sink a lot of current. Each AVR datasheet will have a set of footnotes to the DC Characteristics table that will give current limits.

AVR models that have an AVcc pin will use it to drive the analog pins, but not in all cases.

In a real app it usually comes down to allocating pins for the special functions needed, avoiding interference with ISP, and then layout considerations.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

There ARE some significant differences. One of those often overlooked is the port shared by ADC. For that port t function properly as a digital port, you HAVE TO have AVcc connected! Even if you never use the ADC.

Many port pins have shared functions; SPI or TWI or USART or timer functions are examples. Some of the newer chips have more more external interrupts; these are only on some ports, however.

On some chips, the crystal oscillator pins and/or the reset pin can be switched to GPIO.

So, no, the ports are not equal.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

There ARE some significant differences. One of those often overlooked is the port shared by ADC. For that port t function properly as a digital port, you HAVE TO have AVcc connected! Even if you never use the ADC.

Many port pins have shared functions; SPI or TWI or USART or timer functions are examples. Some of the newer chips have more more external interrupts; these are only on some ports, however.

On some chips, the crystal oscillator pins and/or the reset pin can be switched to GPIO.

So, no, the ports are not equal.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

There are also AVRs with lots of ports going up to PORTF or PORTG, and it might have been that one of the ports was input only (output only??).

- Jani

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

Jepael wrote:
There are also AVRs with lots of ports going up to PORTF or PORTG, and it might have been that one of the ports was input only (output only??).

- Jani

I think that was the mega103 only that had that. I believe that all the modern AVR's have full port functionality. Having said that, there may be a few still out there, and Atmel may do that again in teh future. In any case, if there is a difference, it will be specifically outlined in the data sheet.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

Quote:

I think that was the mega103

Yes, at least the Mega103: PORTC output only, PORTF input only.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

There are huge differences for some applications. Try connecting a serial port - it's only available on certain pins of certain ports. Even if there is a serial port on the port you are working with, it's on different pins.

Try sending PWM out any port, and you'll be bit-banging it. There are PWM pins on some ports that do it in hardware.

The ADC has been covered.

ISP and JTAG are on specific pins on specific ports.

Andy

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

Andy, the question was not about the alternate functions like USART, I2C, PWM etc... It was about the generic GPIO functionality, and in that expect they are all the same (unless otherwise noted in the datasheet)

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

NO all ports are not the same...speaking specifically about PORT functions, some (newer) parts let you toggle the port pins using a single command (I forget what it is), while other parts do not have this type of PORT functionality.

So there, I won the cup of coffee.

Hoyt

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

The original question was: if a microcontroller has several port pins, all of which are being considered for use only as GPIO (general purpose input/ output) is there any difference between them? Eg. between PORTB pin 1 and PORTD pin 5.

Alternate functions are not important here, except in the case that they alter the characteristics of the port pin.

Eg. a port pin that has an analog alternate function (comparator, ADC etc.) might have an analog switch/multiplexer connected. This will be disabled (high impedance) when the alternate function is not being used, but the input capacitance and leakage characteristics of the switch/ multiplexer might have an effect on the input capacitance/ rise time/ input leakage current, etc. of that particular pin when the pin is used as a GPIO.

This might make a small difference (skew?) in the behaviour of the pin wrt the other pins that either have no alternate function or have a purely digital function.

So that was the question. Does anyone have any data / information regarding this point?

If you think education is expensive, try ignorance.

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

emuler wrote:
The original question was: if a microcontroller has several port pins, all of which are being considered for use only as GPIO (general purpose input/ output) is there any difference between them? Eg. between PORTB pin 1 and PORTD pin 5.
[...]
So that was the question. Does anyone have any data / information regarding this point?
There are some differences across devices, such as PA2 on a Tiny28L being output only and capable of higher current. Also, differences can exist when considering a pin as part of a group: some AVRs have current limits for a group on port pins -- thus a pin's limits will be affected by current flow of other pins in its group.

As a sources of informaton, there is only one that should be relied on -- the datasheet for the part. No matter what variations may exist in GPIO characteristics due to whatever factors can be imagined, measured, or deduced, the port pins must fall within the specifications of the datasheet in a correctly functioning AVR part. Thus, one need only to design within the datasheet specifications and if operating outside of those specifications there are no guarantees about how the AVR will respond.

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

Damn the OP (kidding) but this possibility of skew has me worried. If we are reading asynchronous parallel data, say from an external off-board parallel ADC, and a couple of the port pins are slower than the rest, this could mean that when the port is sampled there could be a bad data byte in the mix, instead of simply old data and fresh data. :( Use debouncing techniques for parallel data transfer too???

If you think education is expensive, try ignorance.

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

Quote:
If we are reading asynchronous parallel data, say from an external off-board parallel ADC, and a couple of the port pins are slower than the rest, this could mean that when the port is sampled there could be a bad data byte in the mix,

You should always wait long enough for the lines to settle down, based on the timing diagrams (setup and hold times). That is what avoiding the "skew" is all about. You also generally should have a ready signal to tell you when valid data is coming from your a/d or other async circuit.

Hoyt

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