Skip to main content
Shruthi
Associate III
June 10, 2021
Solved

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

  • June 10, 2021
  • 5 replies
  • 1791 views

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.

This topic has been closed for replies.
Best answer by Tesla DeLorean

RX_BUFF_SIZE tends to ONE ?

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

5 replies

TDK
June 10, 2021

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""."
Tesla DeLorean
Guru
June 10, 2021

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
Shruthi
ShruthiAuthor
Associate III
June 10, 2021

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);

}

Shruthi
ShruthiAuthor
Associate III
June 10, 2021

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);

}

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
June 10, 2021

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..