I have 2 devices connected to my ATMega328 USART pins. One is PL2303 USB to TTL converter and the other is Bluetooth <-> USART adaptor.

I was advised that I should not have 2 devices connected at the same time to the USART pins on my AVR as data corruption may occur if both devices are active at the same time and try to drive the AVR RX pin.

The solution I was suggested was to have diodes on the TX line of each of the devices along with a pull up resistor on the AVR RX line. Something like this .. enter image description here

Can someone explain how this would work?

  • 1
    \$\begingroup\$ mate, why cant you just do software serial? look at the Arduino libraries for it and if you are not already using arduino, then just replicate it for yourself (it's open source, just copy paste and adjust till it works). means you will have no hardware silliness to deal with, just means you must have an extra 2 digital IO pins used. Perhaps you have not enough DIO pins in your current design and you cannot do this? \$\endgroup\$ – KyranF Jul 1 '14 at 11:15
  • 1
    \$\begingroup\$ @KyranF If possible I would avoid going the software route to save on the code space. The USB UART bridge is rarely used. It would only be used to set up the Micro controller parameters in the beginning and then change as and when required. If I can get by without using any foreign code, that would be the best \$\endgroup\$ – Ankit Jul 1 '14 at 11:22
  • \$\begingroup\$ I've built a 1:10 UART switch for a device who had only a single module (The ATMEGA128 I think). I used simple digital MUXes and some 10K pull-up resistors. Took only half a day of work including PCB layout and rapid prototyping. \$\endgroup\$ – user34920 Jul 1 '14 at 19:34
  • \$\begingroup\$ @user34920 any chance of getting the schematic? \$\endgroup\$ – Ankit Jul 1 '14 at 20:45
  • \$\begingroup\$ why not a physical jumper connection like what the Arduino Xbee shield design uses for jumping the UART connection between the USB interface for programming and the Xbee UART connection? \$\endgroup\$ – KyranF Jul 2 '14 at 11:05

Here is a 1 to 10 UART switch using cheap and readily available components. I did this design about 5 years ago. Very simple and works like a charm. I can not give away where it is used but let's say it is very reliable.enter image description here

  • \$\begingroup\$ sure thing, vote me up man :) \$\endgroup\$ – user34920 Jul 19 '14 at 19:47

Okay, I hope I got your problem. The first thing that is irritating to me is the direction of the diodes. You implemented in reverse direction, so the voltage will drop off at the diode and the microcontroller will never receive a signal.

I am also afraid you misunderstood the person telling you to implement the diodes. They are necessary to protect the devices against shorting. You connected two output pins, imagine the situation of one pin driving the line high and the other one drives it low. The diodes prevent high compensating currents which would harm the devices.

But your data is corrupted anyway. You have set up a little bus topology network with your periphal devices and therfore a mechanism of error detection and correction is inevitable. This is an advanced topic and I would advise you to implement another software USART interface which is less complex than implementing a medium access technique.

  • \$\begingroup\$ This analysis is wrong. The diodes are the way they are to allow either input to hold the signal down against the pullup resistor which will otherwise hold it high. It will work, if it can be guaranteed that the transmitters never interrupt each other and output gigh when idle. There are bussed serial schemes that accomplish exactly that using software protocols for who gets to talk. \$\endgroup\$ – Chris Stratton Jul 31 '14 at 23:36

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.