cancel
Showing results for 
Search instead for 
Did you mean: 

UART Receive on STM32F746G only when data is sent from master board

Shruthi
Associate II

I'm communicating between STM32F746G-Discovery ans ESP32 using UART (PC6 and PC7 pins on STM). ESP receives some data at certain intervals over WiFi and transmits it to STM via UART.

On STM I want UART to receive data only when ESP32 has transmitted. Probably STM has to keep listening to UART port until there is data. I want this in non-blocking mode, since there are other peripherals and display working on STM.

How does STM32 know that ESP is sending data over UART and HAL_UART_Receive_IT has to be called to receive it.

1 ACCEPTED SOLUTION

Accepted Solutions

RX_BUFF_SIZE tends to ONE ?

Otherwise you're wait on other characters that may, or may not, turn up in any given time.

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

View solution in original post

5 REPLIES 5
TDK
Guru

HAL_UART_Receive_IT should be called before data is sent. The receive complete interrupt callback is called through an interrupt when data is actually received.

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

You leave HAL_UART_Receive_IT() constantly pending, I'd suggest waiting for one byte, and without any timeout expectations.

When data arrives, the UART will interrupt, and your IRQ/Callback implementation will fetch the data into a buffer, and submit a new HAL_UART_Receive_IT() to catch the next byte. In some worker-task, or periodic loop, you check the buffer for inbound data, and accumulate or process that, parsing when you have enough data to act upon.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Shruthi
Associate II

Could you please suggest how to keep  HAL_UART_Receive_IT() pending and wait for one byte?

So inside callback implementation, should I call HAL_UART_Receive_IT() again to get the next data?

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)

{

// set flag

HAL_UART_Receive_IT(&huart6, Rx_buff, RX_BUFF_SIZE);

}

Could you please suggest how to keep HAL_UART_Receive_IT() pending and wait for one byte?

So inside callback implementation, should I call HAL_UART_Receive_IT() again to get the next data?

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)

{

// set flag

HAL_UART_Receive_IT(&huart6, Rx_buff, RX_BUFF_SIZE);

}

RX_BUFF_SIZE tends to ONE ?

Otherwise you're wait on other characters that may, or may not, turn up in any given time.

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