-2
\$\begingroup\$

I am exploring UARTs on the STM32F103RB on a nucleo board. The board is connected via USB to my laptop, and I can send/receive messages using the HAL_UART_Transmit_IT and HAL_UART_Receive_IT functions.

What I am actually failing to do, is send a message from UART2 to UART3. I wired as follows:

  • UART2 TX (PA2) => UART3 RX (PB11)
  • UART2 RX (PA3) => UART3 TX (PB10)

Then I send a transmit an array of 2 bytes from UART2 to UART3, but the interrupt handler never fires.

So I thought to isolate the problem further, and just connect RX to RX and TX to TX, so that the signals to UART2 are "mirrored" to UART3.

Wiring as follows:

  • UART2 TX (PA2) => UART3 TX (PB10)
  • UART2 RX (PA3) => UART3 RX (PB11)

From the pinout here that I identified the following pins:

enter image description here PA2 and PA3

enter image description here PB10 and PB11

In that setup, I again activate the callback on UART3, send a message from my laptop to UART2 (and thus 'also' to UART3 if my theory works in practice) and hoped to hit the breakpoint in the HAL_UART_RxCpltCallback. But it doesn't work.

The code for completeness:

In the main function:

  // Activate the callback on receive UART3 
  HAL_UART_Receive_IT(&huart3, receive, 2);

  __NOP();
  while (1)
  {
      // Do nothing, all is done via callbacks
  }

(the default setting up of UARTs and GPIO, generated with CubeMX, is left out for readability)

The UART receive callback:

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
  /* Prevent unused argument(s) compilation warning */
  UNUSED(huart);

  if (huart->Instance == huart3.Instance)
  {
      __NOP();
      HAL_UART_Receive_IT(&huart3, (uint8_t *)receive, 2);
  }
}

I am sending a few bytes using a tool (Hercules). It works fine when I change to huart2. So I am sure the code works as it supposed to.

Is it possible to "mirror" UART2 pins to UART3 pins like I did? Or is there something else that comes to mind what I might be doing wrong?

Update

As already explained in the comments, this is not a duplicate of the linked question (otherwise I wouldn't have asked it, since both are mine...). The problem in the linked question was regarding transmitting from UART2 to UART3, the question now is to mirror receiving pins to drill down to the actual issue at hand.

Update 2

Justme was spot on. The problem that I can't mirror the pins is simply because no signal is receive on the PA3 pin. I need to solder a bridge to make that happen, as explained in the user manual:

enter image description here

The answer / comment of Justme is most likely the actual problem that solves my issue.

\$\endgroup\$
9
  • 1
    \$\begingroup\$ You can't wire TX<->TX, that's two outputs connected to each other. Same with the inputs. You aren't showing it, but I'm assuming you are setting up the pins for the UART function? \$\endgroup\$
    – Ron Beyer
    Commented Sep 24, 2019 at 18:10
  • \$\begingroup\$ @RonBeyer So there is no way to do such a "mirror" trick? Would you care to explain why it's not possible. I would expect that wiring PA3 to PB11 would simply transfer all 'bits' to UART3. \$\endgroup\$
    – bas
    Commented Sep 24, 2019 at 18:13
  • 1
    \$\begingroup\$ It's two outputs wired together, TX is an output only, so outputting on one TX doesn't "input" on another TX, since that is set up as an output as well. TX needs to be connected to RX so transmitting on one is received on the other. Maybe what you want to do is wire UART2 TX to UART2 RX? \$\endgroup\$
    – Ron Beyer
    Commented Sep 24, 2019 at 18:15
  • \$\begingroup\$ @RonBeyer, well, I tried that before, to send data from UART2 to UART3, but it doesn't work. Hence I thought to "mirror" the receiving pin of UART2 to the receiving pin of UART3. So I get that connecting the transmit pins together is a bad idea, but why wouldn't the receiving pins not work? Again, I understand that I would never be able to transmit data from UART2 to UART3, but I am trying to receive data send from my computer on UART3 (by "parasiting" the UART2 receiving pin to UART3 receiving pin) \$\endgroup\$
    – bas
    Commented Sep 24, 2019 at 18:30
  • 1
    \$\begingroup\$ Writing 2 RX pins together is fine, and you should expect to receive the same data on both UARTs at the same time. \$\endgroup\$
    – brhans
    Commented Sep 24, 2019 at 18:40

1 Answer 1

1
\$\begingroup\$

Do not wire two or more outputs together. That is a standard rule for push-pull type digital outputs. When other drives low while other drives high, abnormally large current flows from pin to pin and may damage one or both output pins. Also, UART needs TX output connected to RX input for communications.

\$\endgroup\$
3
  • \$\begingroup\$ Hey thanks, that's good to know! Just to be clear, I am trying to parasite the UART2 receiving pin. Is that also not possible? And if not, why not? \$\endgroup\$
    – bas
    Commented Sep 24, 2019 at 18:31
  • \$\begingroup\$ @bas Do you know the board configuration? MCU pins PA2 and PA3 have solder bridges to connect the UART to either Arduino header or ST-Link. By default they are not connected to Arduino header, but to ST-Link. \$\endgroup\$
    – Justme
    Commented Sep 25, 2019 at 4:32
  • \$\begingroup\$ Oh @Justme, thank you so much for this! That really is helpful again. I can read up on this in the user manual en.DM00105823 chapter 6.8. That probably explains why I am having these issues! I will continue this little struggle this evening. When I have it working I will mark your answer as accepted. Thanks a loT! \$\endgroup\$
    – bas
    Commented Sep 25, 2019 at 5:57

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