Half duplex UART from single AVR pin

Smaller microcontrollers like Attiny84 microcontrollers don’t have UART interface and in many cases you may not need it. But if you will want to have an USART option, you will need to user software USART library or write your own routines. You can find many great software USART libraries for that purpose. As a rule you will have to use two pins to establish communication. But if you are tight on I/Os then you can cheat a little and make it work from single pin. Ralph has been experimenting with simple but smart circuit which allows to perform half duplex UART communications with other systems.


The whole trick lies in a small schematic made of diode, transistor and resistor. Diode is only for making one way TX signal path from MCU to other device. Resistor is only for limiting base current. All is left a transistor which works as a key. We need to keep in mind, that when serial line is inactive- it stays in high state. So when microcontroller transmits data, TX on the right keeps transistor open. Thus if Tx from MCU is low, it pulls Rx low and viceversa. When serial adapter wants to transmit 0, it pulls AVR line down through diode, when adapter sends 1, it opens transistor ans since adapter Rx line is high since not used, it sets AVR Rx pin high. All simple and smart. If you wish to try this by yourself, there is an Arduino library available which takes as little as 62 bytes of flash. Takes no RAM for buffering and can work at baud rates from 460.8kbps to 16MHz.

[..Source link..]

Bookmark the permalink.

One Comment

  1. Hi,i have see the schematic and It seems to miss a resistance to protect the two outputs in the event of simultaneous transmission.

Comments are closed