2014-07-17 04:52 PM
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 #discovery2015-05-29 10:28 PM
Hi,
I think you can use __HAL_UART_SEND_REQ(huart, UART_RXDATA_FLUSH_REQUEST); __HAL_UART_CLEAR_IT(huart, UART_CLEAR_OREF); to flush Rx and clear overrun flag. Recently I am using STM32L051xx, and I also need UART. I also think the HAL Uart code is somewhat foolish (Or maybe it would be impossible to write a function to fulfill the whole world, because different application needs different ways to handle the received buffer). Finally what I did is:1. Use CubeMX to generate the code.2. Keep the initialization code for UART.3. Modify code to use my own function for starting Rx and UART IRQ handler, where I could handle my buffer freely. Of course, I could refer to the provided HAL code on how to access UART registers. Actually you have to add ''USART1_IRQHandler'' in your code to use interrupt mode. In this function, call you own IRQ handler, rather than ''HAL_UART_IRQHandler(...)'', which is provided by HAL. Thanks2015-06-03 01:34 AM
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?2015-06-12 04:53 AM
Its extremely disappointing to start out building an application, then find out that the code supplied by the manufacturer is not fit for purpose =(
2016-01-25 06:46 PM
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?
2016-02-11 03:36 AM
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