Is it possible to connect the Rx and Tx pins of the same USART or on two different USARTs on an STM32 discovery board to make a loopback and test the USART?

  • \$\begingroup\$ Yes, as long as you make sure only one device is writing on every line, I believe. There should not be two devices talking on the same line. \$\endgroup\$
    – user17592
    Mar 21, 2013 at 9:43
  • \$\begingroup\$ What do you mean with same line ? I am only using the Tx and Rx pins by the USART (no GPIO) \$\endgroup\$
    – rxjsisfine
    Mar 21, 2013 at 9:47
  • \$\begingroup\$ BTW one of 1-wire implementation works exactly like this: you connect together RX and TX of same USART. \$\endgroup\$
    – Eddy_Em
    Mar 21, 2013 at 9:57
  • \$\begingroup\$ I just tested it now on 2 different USARTs and it worked perfectly. Moving on to same USART :) \$\endgroup\$
    – rxjsisfine
    Mar 21, 2013 at 10:11
  • \$\begingroup\$ You should ask @camil-staps to form his comment as an answer so that you can officially accept it. Despite the miscommunication about multiple USARTS, he did take the time to answer your question. \$\endgroup\$
    – Joe Hass
    Mar 21, 2013 at 10:40

1 Answer 1


You can do anything with USART lines as long as you stick to one basic rule. To understand this rule, you have to understand how the protocol works.

Basically, we have two lines: Rx and Tx. Let's consider these from the device A point of view. Rx is A receives, Tx is A transmits. This means Rx is B transmits, and Tx is B receives. You can now see that these two data lines are one-directional: it's in the circuit who writes and who reads.

It's possible to 'hack' a USART communication: sending data to device X and listening with device Y. Actually, it's a great idea. For example:


simulate this circuit – Schematic created using CircuitLab

In this case, I wanted to read data from A with B, but A sent way too much data. So I added a filter in C. Device A doesn't even notice this change.

You can do really anything with USART lines: listening with multiple devices on one line, et cetera. Just make sure there aren't two devices that have Tx and Tx connected. They will interfere.

  • 1
    \$\begingroup\$ This is interesting, but seems to answer a question substantially different than the one that was asked... \$\endgroup\$ Mar 21, 2013 at 15:12
  • \$\begingroup\$ @ChrisStratton I tried to give a general explanation of the USART which shows the answer ('yes'). You have to see the different USART modules as different devices and I believe this answer is valid then. Or am I misunderstanding something? \$\endgroup\$
    – user17592
    Mar 21, 2013 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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