cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX issue in regard to Preemption Priority on Uarts

NW27
Associate III

Evening,

I have been working on a FreeRTOS project for the last six months and all was going well until the last STMCubeIDE & CubeMX update.

Rightly or wrongly, I have been using the usarts with the below interrupt config

  /* UART8 interrupt Init */

  HAL_NVIC_SetPriority(UART8_IRQn, 0, 0);

  HAL_NVIC_EnableIRQ(UART8_IRQn);

Preemption = 0.

After the last CubeMX update, my four uart comms no longer worked.

After much digging, I found that the CubeMX was setting the Uart Preemption = 5, thus generating the below code.

 /* UART8 interrupt Init */

  HAL_NVIC_SetPriority(UART8_IRQn, 5, 0);

  HAL_NVIC_EnableIRQ(UART8_IRQn);

When it is set at 5, my code no longer works. The uart interrupts do not respond at all.

A value of 5 appears to be a reasonable value or even in the range of 5..15.

Why does my code no longer work??

P.S. I used the CubeMX builder for the original project design and used it's defaults.

It would appear that all  Preemption's = 0 not just the Uart channels.

1 ACCEPTED SOLUTION

Accepted Solutions
Khouloud ZEMMELI
ST Employee

Hello @NW27​ 

Thanks for your feedback,

Well, when FreeRTOS is enabled the Preemption Priority changes.. if you want to set your IP preemption priority to 0 (or other value less than 5) you need to uncheck its "uses FreeRTOS functions".

0693W000005CfVxQAK.png 

Best Regards,

Khouloud

View solution in original post

3 REPLIES 3
Khouloud ZEMMELI
ST Employee

Hello @NW27​ 

Thanks for your feedback,

Well, when FreeRTOS is enabled the Preemption Priority changes.. if you want to set your IP preemption priority to 0 (or other value less than 5) you need to uncheck its "uses FreeRTOS functions".

0693W000005CfVxQAK.png 

Best Regards,

Khouloud

NW27
Associate III

Thanks for your reply.

I understand why the CubeMX is changing it but my question is as to why changing it to 5 from 0 would stop the Uarts from working?

It may depends on your application and some configurations .. as a workaround, you can change the priority as mentioned in the first comment if it suits you.

Hope this helped you to solve the problem you have faced.

Thanks for your feedback

Khouloud