USART and normal port operation

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

I can't find it in datasheet; if I enable USART it overrides normal port operation. Can I in this situation use PINx register to read the IO pin to which Rx USART signal is assigned?

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

One way to find out ;-)

(I've certainly done either/or where I use RXD as a PIN to measure the first start bit but then set RXEN and let the UART take over after that)

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

But didn't you answer that yourself?

Quote:
if I enable USART it overrides normal port operation.

Regards,
Steve A.

The Board helps those that help themselves.

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

clawson wrote:
One way to find out ;-)

(I've certainly done either/or where I use RXD as a PIN to measure the first start bit but then set RXEN and let the UART take over after that)

The information can and should be gleaned from the datasheet.
I'm not a big fan of the poke it and see
what it does method of gathering such data.
It's rather difficult to determine the ranges
over which one's conclusions are correct.

Look for a table with "overriding signals" in its title.

My recollection is that in most cases, e.g. this one,
the PIN registers provide the usual information.
Note that the usual information is delayed
a bit from the signal on the physical pin.

Moderation in all things. -- ancient proverb

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

Well, you forgot to say which AVR you are asking about. Just picking a data sheet at random under the I/O Ports Alternate Port Functions for USART0:

PULL-UP OVERRIDE ENABLE = RXEN0
PULL-UP OVERRIDE VALUE = PORTE0 • PUD
DATA DIRECTION OVERRIDE ENABLE = RXEN0
DIGITAL INPUT PIN = RXD0

Then looking at the alternate port functions schematic shows since DIEOE is not set the PIN register should read whatever is connected to the RXD0 input pin when the USART is enabled. The USART bypasses the metastability synchronization circuit, so the software read port pin will be delayed .5 to 1.5 AVR clock cycles.

[edit] Michael, I see you posted the same thing I was thinking.

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

You can check its behavior/connection in a datasheet of your AVR. It is pretty complicated because an IO construction is like a spaghetti with tens of overriding signals.

No RSTDISBL, no fun!

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

Quote:

The information can and should be gleaned from the datasheet.
I'm not a big fan of the poke it and see
what it does method of gathering such data.
It's rather difficult to determine the ranges
over which one's conclusions are correct.

Michael, generally I'd agree but is there a "range" here? It's surely a binary? Either you can or you cannot. Or are you suggesting that in months with a "R" in them it might suddenly stop/start working when it does/doesn't at other times?!?

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

clawson wrote:
Quote:

The information can and should be gleaned from the datasheet.
I'm not a big fan of the poke it and see
what it does method of gathering such data.
It's rather difficult to determine the ranges
over which one's conclusions are correct.

Michael, generally I'd agree but is there a "range" here? It's surely a binary? Either you can or you cannot. Or are you suggesting that in months with a "R" in them it might suddenly stop/start working when it does/doesn't at other times?!?
Yes.
If the pin is not designed to be
read under the desired conditions,
the month might actually matter.
The readability of the pin might be bit pattern sensitive.
Admittedly, R's are unlikely to be the problem.
Perhaps during USART activities,
the bit that decides readability sort of floats.
During the toasty part of summer,
it allows reading until all the bits around it go to zero.
That doesn't happen very often, so all seems well enough.
Then one hits a month with an "R" in it.
The temperature drops and then one needs two one bits.
This fails about once a minute.
Eventually one decides that the chip must be damaged.
The replacement chip has a different set of bits near the floater.
One of the bits is part of a timer being used in a real time clock.
This chip works perfectly every morning and craps out promptly at noon.

Edit:
I forgot to mention that the guys in charge go to
lunch promptly at 11:30 and come back at 12:15.
This leads to another set of conclusions and around it goes.

Moderation in all things. -- ancient proverb

Last Edited: Fri. Jul 9, 2010 - 02:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

The information can and should be gleaned from the datasheet.

I can't think of any situations where reading PINx does not report the logic state at the pin. Regardless of which alternate function might be active.

[Well, DIDR setting--but not applicable here.]

I could see no hint in the block diagrams and the overriding signals discussion that would indicate that reading PINx for RXDn would be affected. In fact I'd say the datasheet info indicates that it >>is<< readable, though not actually stated as such.

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

theusch wrote:
Quote:

The information can and should be gleaned from the datasheet.

I can't think of any situations where reading PINx does not report the logic state at the pin. Regardless of which alternate function might be active.
skeeve wrote:
My recollection is that in most cases, e.g. this one,
the PIN registers provide the usual information.
Note that the usual information is delayed
a bit from the signal on the physical pin.
Quote:

[Well, DIDR setting--but not applicable here.]

I could see no hint in the block diagrams and the overriding signals discussion that would indicate that reading PINx for RXDn would be affected. In fact I'd say the datasheet info indicates that it >>is<< readable, though not actually stated as such.

On the ATmega168's, the D pins are always readable.
It does take some reading to find it.

Moderation in all things. -- ancient proverb