Showing results for 
Search instead for 
Did you mean: 

[Resolved] USART Tx pin sinks rx pin. HAL UART bug?


Edit: I found the problem, and it is of course my own fault. Careful reading of the transceiver chip datasheet reveals that the Rx pin follows the Tx pin by design on some models, including mine. Leaving this post up for posterity.


I'm having an issue with the USART on STM32F334C8T6. Receiving messages works just fine, but when transmitting I get an overrun error. The cause seems to be that the Rx pin is sunk by the Tx pin, as if there were a diode connecting them (see attached oscilloscope picture - CH1 (yellow): Tx, CH2 (green): Rx).

Physically, the pins are connected to the Rx/Tx pins on a MAX22027 chip - nothing else on the same net. USART2_Tx is on pin 39/PB3 and USART2_Rx on 38/PA15. The problem has persisted on several PCBAs, both assembled by hand and in factory, so I doubt there is an issue with the PCB. I have of course verified that there is no continuity between the pins. In firmware, it is implemented with the HAL library as follows:




huart2.Instance = USART2;

huart2.Init.BaudRate = 115200;

huart2.Init.WordLength = UART_WORDLENGTH_8B;

huart2.Init.StopBits = UART_STOPBITS_1;

huart2.Init.Parity = UART_PARITY_NONE;

huart2.Init.Mode = UART_MODE_TX_RX;

huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;

huart2.Init.OverSampling = UART_OVERSAMPLING_16;

huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

if (HAL_UART_Init(&huart2) != HAL_OK)






 Reception is initiated as follows:






The message is then processed via HAL_UARTEx_RxEventCallback, and a reply is sent as:






Attempting to initiate reception again then fails due to the overrun error bit being set.

What I have tried so far:

  • Moving Tx to another pin. This works.
  • Changing GPIO mode to alternate function open drain, and using pull-ups on one or both pins. No effect.
  • Of course, disabling overrun error or calling the receive function again in the error callback avoids the problem at the cost of not detecting overrun errors properly.

What I'm going to try:

  • Writing my own implementation of UART without using HAL (I assume this will take some time).