2022-02-09 10:13 AM
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
2022-02-09 10:23 AM
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?
2022-02-09 10:39 AM
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?
2022-02-09 03:06 PM
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.
2022-02-09 04:00 PM
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.
2022-02-10 12:19 AM
Thank you for the suggestions!
2022-02-10 12:20 AM
Thank you for these reminders!!
2022-02-10 02:01 AM
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 ?
2022-02-10 02:27 AM
Since I put the Pull up configuration I have not encountered this anomaly on the callbacks anymore. Maybe this was the problem?
2022-02-10 08:18 AM
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.