cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4R5 | FreeRTOS/CMSIS RTOS | Queue from UART ISR issue.

POval.1
Associate II

Hello Everyone,

I am currently working with a dev board based on STM32L4R5 using STM32CubeIDE , HAL libraries and FreeRTOS.

Project: UART2 initialized using the code generator:

Added __HAL_UART_ENABLE_IT() after initialization.

Along with this disabled the " Call HAL Handler " for the USART2 IRQ0693W00000BavyZQAR.jpgAlso modified the IRQ priority0693W00000BawFoQAJ.jpgI have also initialized an queue that is used to send data from the UART IRQ and then received by a task/thread.

 /* Create the queue(s) */
  /* definition and creation of bluetoothDataQueue */
  osMessageQDef(bluetoothDataQueue, 50, uint8_t);
  bluetoothDataQueueHandle = osMessageCreate(osMessageQ(bluetoothDataQueue), NULL);

UART IRQ:

/**
  * @brief This function handles USART2 global interrupt.
  */
void USART2_IRQHandler(void)
{
  /* USER CODE BEGIN USART2_IRQn 0 */
	uint8_t console_rx_byte;
	if ( USART2->ISR & USART_ISR_RXNE_RXFNE )
	{
		console_rx_byte = USART2->RDR;
		osMessagePut( USART2_RxQueue, rxData,  0 );
	}
 
  /* USER CODE END USART2_IRQn 0 */
  /* USER CODE BEGIN USART2_IRQn 1 */
 
  /* USER CODE END USART2_IRQn 1 */
}

Issue:

When I comment out the line:

osMessagePut( USART2_RxQueue, rxData, 0 );

There is no issue encountered. But when the Line is added, the HAL_Init() function does not return.

From basic debugging the problem lies here in the HAL_Init()

 /* Use SysTick as time base source and configure 1ms tick (default clock after Reset is MSI) */
  if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
  {
    status = HAL_ERROR;
  }
  else
  {
    /* Init the low level hardware */
    HAL_MspInit();
  }

Could someone please let me know If I am doing something wrong here.

Thank you.

3 REPLIES 3

Hello @POval.1​ ,

Can you please share your example for further check ?

Thanks in advance.

BeST Regards,

Walid

wandering_engr
Associate

I am encountering the exact same issue with the nucleus F443ze board. Have you find the solution?

wandering_engr
Associate

I found the solution for my case, i forgot the enable the USE_NEWLIB_REENTRANT setting for Freertos in cubemx.