Skip to main content
Visitor II
June 11, 2021
Question

STM32F103 HAL UART Receive Interrupt not working

  • June 11, 2021
  • 2 replies
  • 971 views

I'me using STM32F103C8 MCU with Stm32CubeIDE 1.6.1.

Project uses CMSIS OS v1 and 3 UARTs enabled global interrupts. UART settings 57600 8 N 1 for all three.

Interrupts handled in the callback:

uint8_t			rxByte[UART_COUNT] = {0};
QueueHandle_t	uartQueues[UART_COUNT] = {0};
 
UART_HandleTypeDef*	uartList[UART_COUNT] = {
		&huart1,	// UART_CONSOLE
		&huart2,	// UART_ENG1
		&huart3,	// UART_ENG2
};
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	BaseType_t xHigerPriorityTaskWoken;
 
	for (int u = 0; u < UART_COUNT; ++u) {
		if (huart == uartList[u])
		{
			if (uartList[u]->RxXferCount == 0){
				if (uartQueues[u]) xQueueSendFromISR(uartQueues[u], &rxByte[u], &xHigerPriorityTaskWoken);
				HAL_UART_Receive_IT(uartList[u], &rxByte[u], 1);
			}
			return;
		}
	}
}

Everything works, but in unpredictable period one of three USARTs stop receiving data in HAL_UART_BUSY state. It has random fashion.

    This topic has been closed for replies.

    2 replies

    Graduate II
    June 11, 2021

    So likely waiting on actual reception. Is the UART flagging some kind of error status?

    Viewing the UART registers in a debugger will result in unpredictable behaviour.

    Super User
    June 12, 2021

    > Is the UART flagging some kind of error status?

    +1

    UART stops receiving when overrun error is unhandled.

    JW