Skip to main content
VR_it
Associate II
April 19, 2019
Question

How can I invoke UART_Receive_IT() automatically when I receive a data?

I am new to STM32 and CubeMX. I need to write a program to send and receive data from a module via UART port. I have to send(Transmit) a data to that module(for eg. M66). Then I would return to do some other tasks. once the M66 send a response to that, my seial-port-receive-function(HAL_UART_Receive_IT) has to be invoked and receive that response. How can I achieve this? or Shall I call HAL_UART_Receive in interrupt mode and let it check for the data from module?

I need to complete this ASAP...Thanks in Advance

This topic has been closed for replies.

2 replies

e-zeki
Associate III
April 19, 2019

"my seial-port-receive-function(HAL_UART_Receive_IT) has to be invoked and receive that response. "

That's pretty much HAL_UART_Receive_IT() does.

you can initialize uart interrupt to receive data with HAL_UART_Receive_IT() so it only goes to check when reception occurs.

Tesla DeLorean
Guru
April 19, 2019

UART_Receive_IT() starts the process, and then you use it in your callback function to reinvoke it next time.

You'd probably want to use it in one byte mode, be also be conscious that the callback happens in interrupt context, and you must complete within a single byte time, and not block.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..