cancel
Showing results for 
Search instead for 
Did you mean: 

osMessagePut usages in UART ISR

louiey
Associate II

Hi.

I'm using STM32F746-DISCOVERY EVM with CubeIDE (v1.4.2)

I'm trying to send uart rx char via osMessagePut API in uart ISR to other task which waits uart que.

in uart isr callback, when I get rx char, I send rx byte via osMessagePut ().

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	if(huart->Instance == cliPort)
	{
		osMessagePut (uartQueHandle, huart->Instance->RDR & (uint16_t)0x01FF, 0);
	}
}

and receive part is below

uint16_t bsp_uart_gets(uint8_t* buf)
{
	HAL_StatusTypeDef result;
	uint16_t size = 0;
	char ch;
	while(1)
	{
		result = HAL_UART_Receive_IT(cliHandle, (uint8_t*)&ch, 1);
		if(result != HAL_OK)
		{
			LOG("result - %d - %c\n", result, ch);
		}
		
		osEvent evt = osMessageGet (uartQueHandle, osWaitForever);
		if(evt.status == osEventMessage)
		{
			ch = evt.value.v;
			// in case of line end, return
			if( (ch == '\n') || (ch == '\r') )
			{
				return size;
			}
			
			buf[size++] = ch;
			if(size > 64*2)
				size = 0;
		}
		else
		{
			
		}
	}
}

So when I get uart rx interrupt, I send rx char via osMessagePut().

But when I call osMessagePut(), it stuck at port.c, vPortValidateInterruptPriority/configASSERT( ucCurrentPriority >= ucMaxSysCallPriority ).

Looks relates with interrupt priority so I have changed uart interrupt priority but still same issue happened. (it was '0' and changed to '8'/'15' and same)

0693W000004KKLoQAO.jpg 

Actually I used this code for long time and lately I have a new project and testing but it causes problem, interrupt priority issue.

I read many information and it seems to be interrupt priority issue but not sure how to fix this.

Can you help how to handle this?

1 ACCEPTED SOLUTION

Accepted Solutions
louiey
Associate II

Manually set its interrupt priority to "5" and it works.

Waiting for next release.

View solution in original post

2 REPLIES 2

Hi @louiey​ 

Thanks for the feedback, NVIC does not support FreeRTOS in STM32CubeMX v6.0.0 and so the SysTick_IRQn priority preemption is left intact (left at 0) when FreeRTOS is enabled. The next STM32CubeMX version will correct this.

Best regards,

Nesrine

louiey
Associate II

Manually set its interrupt priority to "5" and it works.

Waiting for next release.