5
\$\begingroup\$

I'm trying to establish communication between 2 MCU using TX/RX over 1 line. Please refer to the image.

Questions:

  1. Will this work? There will be an echo for sure.

    If MCU 1 sends a "123" signal, MCU 1 and MCU 2 will receive "123" at the same time.

    If MCU 2 sends a "678" signal, MCU 2 and MCU 1 will receive "678" at the same time.

    Is this assumption correct?

  2. In the long run, will it damage the MCU?

Thank you.

enter image description here

\$\endgroup\$
12
\$\begingroup\$

While your assumption of how the RX works is correct, care needs to be taken with the two TX driving the same line. You want to at least buffer the TX with a reverse diode and a pull-up resistor, like this:

enter image description here

Doing something like this is nothing new and there are lots of references on the internet. This configuration will actually be useful to help detect transmission errors as the transmitter also receives the loop back data.

You might want to look up some stuff on the internet such as this and this.

\$\endgroup\$
  • \$\begingroup\$ Thanks @sybreon. This is helpful. From the articles, it seems like the MCU 2 doesn't even need its own power. It can tap the power from the MCU 1, Parasitic power. Is this correct? \$\endgroup\$ – Daniel Aug 30 '11 at 4:34
  • \$\begingroup\$ @Daniel - The second link does point to 1-wire, a communication/power scheme that multiplexes power and data on one wire (plus a return path). However, I'd suggest that you first get the circuit working with power to both MCUs, then experiment with 1-wire if necessary. That, or use MCUs, sensors, and/or transceivers designed for 1-Wire communication. \$\endgroup\$ – Kevin Vermeer Aug 30 '11 at 11:23
  • \$\begingroup\$ The AVR Xmega Xplained board connects TX and RX to one line using 220ohm resistors to implement the PDI protocol (synchronous UART with a separate clock line). How does that compare to a diode? \$\endgroup\$ – joeforker Aug 30 '11 at 12:40
  • \$\begingroup\$ @sybreon- when u say "This configuration will actually be useful to help detect transmission errors as the transmitter also receives the loop back data", this cannot be completely true right?. You can only check upto the point where the Tx is looped back to RX. If the wire is cut beyond that point, it cant be detected right??. \$\endgroup\$ – Akshay Immanuel D May 24 '16 at 4:37
1
\$\begingroup\$

It's very common for any modern MCU to have UART pins shared with GPIO pins. Typically the primary function is GPIO and the secondary function is UART.

This means that the diodes are not necessary. So, to implement a 1-wire bus using UARTs, consider the following.

Say we have an MCU with pins A0 and A1:

  • The primary function pins A0 and A1 is GPIO-0 and GPIO-1, respectively.
  • The secondary function for pins A0 and A1 is UART-TX and UART-RX, repectively.

Software Design

Initial setup (receive):

  • Set Pin A0 to the primary GPIO function (in high impedance input mode).
  • Set Pin A1 to the secondary UART-RX function.

To transmit:

  • Set pin A0 to secondary UART-TX function.
  • Send bytestream
  • For each TX byte, an RX byte will be received. Assume transmit failed if they do not match.
  • Set pin A0 back to primary GPIO function.

Hardware Design

  • Insert a 1K resistor at each UART-TX pin -- to protect against a short-circuit when 2 or more transmitters send simultaneously.
  • Insert a 100K pull-up resistor from the data-bus to VCC -- to stabilize the bus when no-one is transmitting.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.