cancel
Showing results for 
Search instead for 
Did you mean: 

Receive large size text file through UART Interrupt

Sivakumarzcs128
Associate II

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.

4 REPLIES 4
Pavel A.
Evangelist III

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

 

Sivakumarzcs128
Associate II

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

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

 

What is sending this text file? What are you doing with this text file? Are you saving it all to RAM or to external memory? 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.