UART idles low

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

My understanding is that the uart lines are to idle high but there appears to a significant percentage of chips trafficing through that appear to idle low. . .convinced that the uart is configured correctly[USCnA/B/C registers] along with the port pins[in this case, it's Port E of a mega128] RXD0 is a 0 for input, TXD0 is a 1 for output, I'm interested in finding out whether any 'freak has seen anything similar. . .in the meantime, I'll comb through the code

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

do you mean low or high at the logic level or at the RS232 level? Some RS232 level shifters invert the logic polarity. At the logic level, there is no standard on data polarity, nor any definition for what level shifter does when supplied with a floating (high impedance) input signal.

Most (or all) of the RS232 converters invert.

At the RS232 lines

"Voltages of -3v to -25v with respect to signal ground (pin 7) are considered logic '1' (the marking condition), whereas voltages of +3v to +25v are considered logic '0' (the spacing condition)."

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

*All* RS232 converters invert; at idle, the voltages should be below -3v relative to ground. At the Tx and RX pins - if correctly configured - you should see logic high at idle.

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

Just to add to the above replies - you do know that to connect an AVR UART to a PC COMM port you need to add an intervening inverter/level converter such as a MAX232 don't you? As they say this both converts TTL 0V..5V (or 0V..3.3V) to RS232 -12V..+12V levels and INVERTs the signals while it's at it.

If you are connecting two AVRs together using their UARTs then you need nothing in between - both are "upside down" but the effect cancels each other. But if you connect to an external device like a GPS or a GSM modem then you may get away with remaining at 0V..5V TTL levels but some form of transistor inversion may be required.

Cliff

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

And further clarification clarification... if you're using a USB-serial chip, it looks like a serial port at both ends; you *don't* need an inverter between it and the USB chip.

Cliff, the AVR UART inputs and outputs are normal logic-1-high levels, not inverted. It's only inverted relative to the (inverted) RS232 levels.

Neil

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

I did get caught once with such an issue - dodgy software was twiddling the wrong bits on the uart - thus disabling it. Had me confused for a while especially since I was dealing with a '2560 that I hadn't used before.

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

Yes. On most (all?) AVR, enabling the uart tx and rx overrides the other port commands.

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

Sdviveros wrote:
...RXD0 is a 0 for input, TXD0 is a 1 for output...

I see nothing wrong with this. RXD will be floating, possibly low, unless something external is driving it. TXD will be high when idle.

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

In fact, many PC COM ports will tolerate TTL voltages and interpret them correctly as 0s or 1s. But you still need the inverter part. Some USB-to-RS232 converters (full product, not a chip) even output TTL levels (inverted, as an RS-232).

Embedded Dreams
One day, knowledge will replace money.

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

Nuno wrote:
In fact, many PC COM ports will tolerate TTL voltages and interpret them correctly as 0s or 1s.

Not a good idea. Many, many horror stories like "works here, not there, worked Monday not Tuesday, Doesn't work on most laptops" ...

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

Very bad idea. Given that an input voltage between -3 and +3 volts is an undefined level, you're taking a big risk.

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

I wouldn't use it in a commercial product, but for hobby stuff it has never let me down.

Embedded Dreams
One day, knowledge will replace money.