Half duplex UART from single AVR pin

Smaller microcontrollers like Attiny84 microcontrollers don’t have UART interfaces, and you may not need them in many cases. But if you want a USART option, you will need to use 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, you can cheat a little and make it work from a single pin. Ralph has been experimenting with the simple but intelligent circuit, which allows performing half duplex UART communications with other systems.

1Wire_UART

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. The resistor is only for limiting base current. All is left a transistor which works as a key. We need to remember that when the serial line is inactive, it stays in the 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 the serial adapter wants to transmit 0, it pulls AVR line down through the diode; when the adapter sends 1, it opens the transistor, and since adapter Rx line is high since not used, it sets the AVR Rx to pin high. All are simple and intelligent. If you wish to try this by yourself, an Arduino library that takes as little as 62 bytes of flash is available. It takes no RAM for buffering and can work at baud rates from 460.8kbps to 16MHz.

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