Skip to main content
Associate II
March 26, 2024
Question

Receive large size text file through UART Interrupt

  • March 26, 2024
  • 4 replies
  • 1303 views

Hi, 

 I need to receive approximately 300kb size text file through UART interrupt mode in Nucleo H7 board. But only 65535 bytes are received. i used HAL_UART_Receive_IT for this.

This topic has been closed for replies.

4 replies

Pavel A.
March 26, 2024

This is because the size argument of HAL_UART_Receive_IT is 16-bit

https://github.com/STMicroelectronics/stm32h7xx_hal_driver/blob/fec141ce999da655a48e1a15db83a72d564a1312/Src/stm32h7xx_hal_uart.c#L1359

Receiving 300 KB of data in one HAL_UART_Receive_IT call is unusual. This is why no one else noticed this limitation ))

 

Associate II
March 27, 2024

Is there any other methods to send the text files completely using UART interrupt

Bob S
Super User
March 27, 2024

You can use XMODEM (or YMODEM or ZMODEM) protocols to break the file into smaller manageable chunks.  ST has example ymodem code (a very minimal implementation) in some of their app notes.  Search st.com for "ymodem" to find them.  Or any of the open source versions.

If you can't do that you best bet is to use circular DMA to continuously receive data and then poll the receive buffer to pull out data as it comes in. @Tilen MAJERLE has code for this on his github site https://github.com/MaJerle/stm32-usart-uart-dma-rx-tx