cancel
Showing results for 
Search instead for 
Did you mean: 

Is it correct that HAL_UART_RxHalfCpltCallback and HAL_UART_RxCpltCallback are invoked even when there is nothing connected to the Tx and Rx pins of my microcontroller?

VNava.1
Associate III

Hi community!

I would like to understand if it is normal that when I use DMA method to receive data the callback related to this method are invoked even when there is nothing connected to the Tx and Rx pins of my microcontroller.

I'm using a NUCLEO-F303K8

Thanks in advance

9 REPLIES 9
VNava.1
Associate III

UPDATE_1: I'm using two UART peripherals: UART1 and UART2. The UART1 is used to communicate with another controller while the UART2 is used to print in a terminal some debug information. Is it possible that the reception callbacks for UART1 are invoked also when I send something to the terminal with the UART2?

VNava.1
Associate III

UPDATE_2: As I said previously, In my application I'm communicating with another controller by means of UART1 both in transmission and in reception. If I don't connect anything to the pins UART1TX and UART1RX of my controller I can see that the reception collbacks are invoked and Moreover, the msg received is the msg that I want to transmit by means of UART1Tx. Is it possible that there is some embedded loopback mode that I need to uncheck?

TDK
Guru

Callbacks aren't called unless it receives data. There is no internal connection between USART1 and USART2, so something is connecting them externally, or you are misinterpreting what is going on. Verify that the pin is idle with a scope. Look at the board schematic to verify hardware connections, or the lack thereof.

If you feel a post has answered your question, please click "Accept as Solution".
Piranha
Chief II

Just a reminder... HAL_UART_RxHalfCpltCallback()/HAL_UART_RxCpltCallback() are single unified callbacks for all peripheral instances. That means the user code has to find out for which instance it has been called every time. It's a kindergarten level API design by incompetent people... Though later they introduced a still bad but a bit more usable approach with the use of USE_HAL_UART_REGISTER_CALLBACKS and HAL_UART_RegisterCallback(), with which one can set separate functions for each peripheral instance.

Also a reminder... Floating pins can and will pick up a noise/signal from other pins, routes and basically any EMI source. It could be the routes for the other UART instance.

VNava.1
Associate III

Thank you for the suggestions!

Thank you for these reminders!!

I remove the UART2 from my application and now the process uses only the UART1 peripheral. Also in this case the callbacks for the reception are called even when the URAT1TX and UART1RX pins are not connected with the other microcontroller. I considered your last reminder and I checked that UART1 pins are configure with NO_PULL_UP. So I tried to configure these pins with a PULL_UP. Now the callbacks are not invoked when the two UART1 pins are disconnected while they are correctly called when the two pins are connected. Now, I would like to understand which is the correct configuration. Do you have another...reminder ?

Since I put the Pull up configuration I have not encountered this anomaly on the callbacks anymore. Maybe this was the problem?

It sounds as though that is the solution, because the open RX input picked up enough noise to trigger it. Interesting that the input is so sensitive (I don't know the specs that wel...) - maybe check your schematic and board / layout for noise sources close to the RX pin and pcb tracks.