cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 HAL UART Receive Interrupt not working

RaJa
Associate II

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.

2 REPLIES 2

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

> Is the UART flagging some kind of error status?

+1

UART stops receiving when overrun error is unhandled.

JW