Skip to main content
rajpaged
Associate II
July 17, 2014
Question

Best way to use HAL UART Receiver IT Function?

  • July 17, 2014
  • 14 replies
  • 10474 views
Posted on July 18, 2014 at 01:52

I'm trying to understand how the interrupt handlers works for the HAL UART module. I have the UART1 set with global interrupts using stm32cubeMX generated code, and am able to send and receive data into buffers.

Using the HAL_UART_Receive_IT() function, I see the application enter the HAL_UART_RxCpltCallback function once the buffer is full. How do I ready the module for another receive interrupt when I'm done in this callback handler? If I issue the HAL_UART_Receive_IT() function again at the end of the handler, my application gets stuck after a few receive interrupts.

I essentially want to use the UART to receive various console like commands (each different in length) so plan to use the callback handler to house a table of possible commands and act on them. As the interrupt only triggers on a full buffer, would I need to read single characters at a time, or is there a better way of doing this?

#stm32-hal-uart #hal #stm32f4 #uart #discovery
This topic has been closed for replies.

14 replies

vinayakrjoshi
Associate
June 3, 2015
Posted on June 03, 2015 at 10:34

Hi Heisenberg,

I am trying to transmit the data using 

HAL_UART_Transmit_IT(&huart1, (uint8_t*)aTxEndMessage, len);

but if i define aTxEndMessage buffer locally, I am getting garbage data. but when i define it Globally i am getting right data. Don't know why? 

What's the problem in my case?

sammy_346
Visitor II
June 12, 2015
Posted on June 12, 2015 at 13:53

Its extremely disappointing to start out building an application, then find out that the code supplied by the manufacturer is not fit for purpose =(

dree86
Associate II
January 26, 2016
Posted on January 26, 2016 at 03:46

hei heisenberg

__HAL_UART_FLUSH_DRREGISTER()  seems no more. What is the replace function of it?

 

And I face problem with TX RX STM32. Its not stable. This function HAL_UART_ErrorCallback sometime called. I am using non blocking mode (IT).

I am using STM32L053 Discovery. What points to taken to init UART and to send and receive UART?
abdulhakeem
Visitor II
February 11, 2016
Posted on February 11, 2016 at 12:36

Hi Adri 

I am also using same STM32L0538 DISCO.

I am also facing same problem related UART .If resolved your problem please kindly share the source code of UART TX and RX.

Thank in advance