USART hardware logic level invertable? Guess not?

I am looking at whether I can invert the USART logic level used by ATMEGA2560 by modifying register values so idle is LOW instead of HIGH. I found this post about ATMEGA328:

http://forum.arduino.cc/index.php?topic=69849.0

I'm using MEGA2560 so this is the relevant doc:

www.atmel.com/images/doc2549.pdf?

Just want to have another pair of eyes look at it before I say, no not possible.

Chapter 22 is USART, page 210 under figure 22-4 has the same verdict as the previous post:

St Start bit, always low.
(n) Data bits (0 to 8).
P Parity bit. Can be odd or even.
Sp Stop bit, always high.
IDLE No transfers on the communication line (RxDn or TxDn). An IDLE line
must be high.

As far as I know, it is like Nick Gammon wrote: UART/USART setting the logic to start at LOW instead of HIGH - #6 by nickgammon - Programming Questions - Arduino Forum

You can make an inverted version of the SoftwareSerial library, or use a hardware inverter.

The source code of the SoftwareSerial is at: arduino-1.0.5/libraries/SoftwareSerial/SoftwareSerial.cpp
As you can see in the source code, there is a undocumented third parameter for an inverted signal. So it has already be done for you.

SoftwareSerial mySerial (10, 11, true);    // RX, TX, inverted

I've never seen a UART that will invert the signals, as above, SS or an external inverter.


Rob

I've never seen a UART that will invert the signals

The PIC24 and PIC32 UARTS apparently have bits to invert receive or transmit polarity. RXINV and TXINV control bits.
I think a fair number of USB/Serial chips have this capability as well (FT230X has it, for example.) I believe that some of the cheaper "rs232 to usb" dongles use such a feature to "fake" rs232, since many rs232 receivers will interpret inverted 5V TTL levels "correctly"...

Maybe I should be looking at using PICs :slight_smile: It's a nice feature and an obvious one really, but I've never seen it before.


Rob

Thanks guys. I am involved in a project that purchased a lot of maxbotix sonic rangers that output "RS232" signals. They're actually just inverted TTL. I am just trying to find a way to reduce the number of components. Right now a ttl rs232 converter is used. Some engineer insisted to use it at the sight of the "rs232" word. Since the ranger only outputs, the converter is just acting as an expensive inverter. No signal is sent to the sensor at +-12 V. I should have borrowed a scope and show that engineer the signal is 5V, who himself must have never bothered to check. I blame maxbotix too. Too many elec. engineers that don't know what they are talking about and use wrong wording or making assumptions and never bother to check. Took a physicist in this engineering project to write all the code and integrate all components.

Yes, RS-232 is routinely used when referring to all async serial, regardless of the voltage levels. I see this all the time, even in professional documents.

Took a physicist in this engineering project to write all the code and integrate all components.

That would be you? :slight_smile:


Rob

Graynomad:
Yes, RS-232 is routinely used when referring to all async serial, regardless of the voltage levels. I see this all the time, even in professional documents.

Took a physicist in this engineering project to write all the code and integrate all components.

That would be you? :slight_smile:


Rob

But is it correct? I thought the voltage is part of the RS232 specification. Yeah that would be me. I am a physicist by trade. Programming is just what I do since childhood.

No, it's not correct. True RS232 will have signals that swing between -3 to -25 up to +3 to +25.

Got it! Thanks.