callbackstm32uarthal

STM32 F103 UART callback works only once


I'm using UART RX callback code from here https://www.programmersought.com/article/68737014549/

Looks like this non-blocking RX processing doesn't work in background as expected

/* USER CODE BEGIN USART1_Init 2 */
HAL_UART_Receive_IT(&huart1, (uint8_t *)aRxBuffer1, RXBUFFERSIZE); //This function will turn on the receive interrupt: flag bit UART_IT_RXNE, and set the receive buffer and the maximum amount of data received by the receive buffer */

__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
/* USER CODE END USART1_Init 2 */

I receive only once and can't process next incoming bytes, because RX buffer keeps only old value.

Is it something with example or HAL's issue?


Solution

  • if you using DMA mode you must select circular buffer instead of normal buffer to refresh it on receiving new data.