inverted RS232 on AVRmega16

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

Hi,

Do anyone know how I can invert the rs232 on my AVRMega16?

/Gert

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

That is a very tricky question, Gert.

The Mega16 UART does not use RS232 signal levels. If you want to communicate with an RS232 device (like a PC serial port) the normal method is to use an RS232 transceiver of some type. Maxim has a pile of models (MAX232, MAX202, etc.) as do other manufacturers.

That is what I think of when you say "invert". If you really want to invert for some reason, use an inverter chip. Or invert the levels interanlly after reading/before writing.

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

@Lee:
I think, inverting the bits after reading/before writing will not work with standard-uarts, because this would not invert the start- and stopbit and the other device would not sync to the start-condition.
If you have enough free resources in your mcu, you could write an inverted software-uart.
/Martin.

/Martin.

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

We don't really know >>what<< Gert is asking, do we Martin? :) I suspect he needs a MAX232 or equivalent to talk RS232 to the outside world with his Mega's UART.

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

Sounds to me as though he wants to talk to a PC, and wants the bits inverted to get it to the RS-232 "standard levels". Although 0-5V is not RS232, most computers and laptops can now communicate sucessfully at these levels...I've done it in a few quick projects where putting a dedicated transciever isn't economical (ie: i've made a tiny15 talk to a PC COM port).

That being said, it is correct that you cannot use the on-board UART to accomplish this. There is no way to force the hardware uart to invert all the bits (including start/stop). You will have to write your own software uart to do this.

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

I used a 74LS04 but its not from ATMEL :oops:

/Bingo

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

There are a number of devices that use "TTL RS-232". This is actually quite old, going back to VIC20s and other "personal computers" of that era. Real RS232 was considered too costly to put into a low-cost home computer. And, most RS-232 interfaces of the time tended to tolerate the out-of-spec operation.

Generally, what is needed is simply a "TTL" inverter, one each on the input and output. The logic does not have to be strict TTL, as CMOS is generally fine.

Some caution is needed on the receive side if it is ever going to be driven by a true RS-232 (bipolar) signal. Such a signal can fry the logic input, either on the negative-going swing or on the positive when it goes above the local Vcc. I would add a series resistor to the input (a few K, perhaps), and diodes to ground and Vcc. Yes, most CMOS logic has protection diodes at the inputs but I would NOT rely on it for this kind of sitution. I would also use Schottky diodes, not junction ones.

Jim

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

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

Progressive resources sells a little rs232 chip with a db9 on a bd.... 4 pin connector +5, gnd, rx, tx about $20

Imagecraft compiler user