Pin configuration for XMEGA UART

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

How do I have to configure the RX-Pin of a UART? Should I configure it with internal pullup resistor? This is what I have done in earlier projects on other controllers.

For a XMEGA it will look probably like this:

PINnCTRL.OPC=0; // TOTEM (reset value)

or

PINnCTRL.OPC=3; // PULLUP

Or does configuring such a pin as a UART RX overwrite this setting?

The application note AVR1307 does not mention this and the example code does not use PINnCTRL. Thanks in advance for any comments.

Edit: My intention is to avoid dummy interrupts if the RX signal is disconnected. An alternative is of course an external pull up resistor...

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

Interesting question.
Although I've used the Xmega USART, I haven't tried specifically setting the Pull-Up or Pull-Down resistors.
I would expect it to work, i.e. I would expect it to be possible to activate them.

The data sheet notes that the RxD pin must be in Input Mode. As that is the default power up mode, I don't specifically set it in input mode. If one was using the pin for some other function, then switching to USART mode, one would have to configure the pin for input.

My understaning is that the Pin Control Circuitry is tied to the physical pins, and the various modules tie to the Pin Control Circuitry. Hence any pin can have its sense inverted, etc. The USART block diagram clearly shows the Pin Control Circuitry as part of the system, so you should be able to configure the RxD pin for Totum-pole with Pull-Up/Down as needed, then set the Direction Register for that pin to input.

While we are discussing the USART setup, note that although no particular setup is required for the RxD pin, (except in your case, above), the TxD pin DOES require specific setup and initialization.

JC

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

ce wrote:
avoid dummy interrupts if the RX signal is disconnected
Disconnected from what?
If you are using a level converter, like a MAX3232, then you don't need to worry about having the cable disconnected.
But if you are connecting directly to another device that takes 3.3V levels, then yes, you can use the internall pull up.

PORTC.PIN2CTRL  = 0x18; // Pull up on pin PC2
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Indeed I am not using a MAX232 converter. Are you sure that configuring the internal pull up works also if you user the PIN as UART RX?

I agree with DocJC that it will probably work. But It's not 100% clear in the data sheet.