5
\$\begingroup\$

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?

Kevin Reid
7,6401 gold badge27 silver badges44 bronze badges
asked Mar 21, 2013 at 9:40
\$\endgroup\$
5
  • \$\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\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented Mar 21, 2013 at 10:40

1 Answer 1

3
\$\begingroup\$

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:

schematic

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.

answered Mar 21, 2013 at 13:08
\$\endgroup\$
2
  • 1
    \$\begingroup\$ This is interesting, but seems to answer a question substantially different than the one that was asked... \$\endgroup\$ Commented 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\$ Commented Mar 21, 2013 at 15:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.