Since you are designing everything from scratch, it would not append with good specifications, written on paper, with cabling diagram, connectors pins definitions, etc…And this will cost nothing.
Lines being crossed is different than line polarity. I can see where lines being crossed can happen, but an accidental polarity switch seems quite unlikely.
You could listen to both lines, and transmit on the opposite one. That would require dual transmiters and receivers.
In any case there is not a control to the LPC12xx UART to invert the data, for that matter I’m not aware of any UARTs that support this.
Yes I have control of the design but not the cables being plugged in. Also, as nodes can be daisy-chained you would have to ensure that the user used crossed cables. I can also cross the signal between the two RJ sockets on the PCB, but then you have to be careful which one you plug into.
I want the system to work no matter what cable is connected to what socket.
This means that A and B may be swapped or not and the swapping is essentially random, based on what cables are used. This in turn means that the data from/to the 485 transceiver may be inverted or not and this has to be dealt with.
I know I can specify what cables to use, but the user-friendly way to do this is to just handle it with no fuss.
You could listen to both lines, and transmit on the opposite one. That would require dual transmiters and receivers.
Which of course I'd like to avoid :)
Another way is to use two XOR gates in the Rx and Tx lines. But I’d like to do this with no extra hardware.
In any case there is not a control to the LPC12xx UART to invert the data, for that matter I’m not aware of any UARTs that support this.
True, and neither am I. However the LPC can invert an IO pin's input, so if that inversion is right on the "outside" before any internal functions have access to the signal then the UART will see either an inverted or non-inverted signal and it will work.
Conversely of the open-drain circuitry is the last thing that happens before the signal leaves the chip then I can effectively invert the UART output but setting open drain mode and using a pullup resistor.
Being open drain does not invert the signal, and the logic of the IOs is to select one of 4 or 8 functions, one being the UART and one being an IO. The IO functions allow open drain, but not the UART.
Many 485 protocols are polarity insensitve, but that would not be a case when using a UART.
If they can swap TXD and RXD, I don’t see how you’ll get around not having 2 receivers, and transmitters, as the important thing about 485 is the differential nature, and just using XOR gates wont’w swap the line, and muxes won’t do it either as you won’t get the driver or receiver characteristics of 485 with vanilla logic.
Being open drain does not invert the signal, and the logic of the IOs is to select one of 4 or 8 functions, one being the UART and one being an IO. The IO functions allow open drain, but not the UART.
OK, got that, I only decided to use an LPC three days ago so still coming up to speed with them.
Thanks for getting me straight on that. So external circuitry is required.
If they can swap TXD and RXD
Not swapping TXD and RXD, just A and B. So the UART connections are the same just the logic levels into and out of the LPC are inverted.
We had a long discussion about swapping A and B on AVRfreaks a while back. General consensus was that swapping A and B simply inverts the levels on the logic side of the chip.