cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_NVIC_SetPriority assert issue and incorrect Preempt Priority value for the STM32F4 / STM32G4 /...

OGhis
Senior

i had used used cubemx 5.5 and in 'System Core' => 'SYS' configurated the 'Time Source' as TIM7 and enabled the option 'Enable Full Assert'

On running the project a had an assert that fails over the Preempt Priority value for the timer (TIM7)

The PreemptPriority value for the HAL_NVIC_SetPriority variate from 0-15, but when the HAL_RCC_ClockConfig function is called is this value 16. (max 4 bits long) .

The reason comes from the File STM32F4xx_hal.c where uwTickPrio is defined as follow:

uint32_t uwTickPrio  = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */

In main.c with the function HAL_Init() is the PreemptPrioity value correct but with the SystemClock_Config() function is the PreemptPrioity value overridden by the uwTickPrio  value.

The issue comes from the WEAK function HAL_InitTick in the weak function is the uwTickPrio  initialized, but the HAL_InitTick is overridden in the stm32f4xx_hal_timebase_tim.c

So the only possible solution i had found is to add the following code before HAL_NVIC_SetPriority(TIM7_IRQn, TickPriority ,0); in the HAL_InitTick of the file stm32f4xx_hal_timebase_tim.c that was generated by cubemx.

uwTickPrio = TickPriority;

21 REPLIES 21

Hello @Charles Miller​ 

I added @Khouloud ZEMMELI​  and @Sara BEN HADJ YAHYA​ in this post to check and provide a status update about this issue (internal ticket 81033).

Thanks

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
MGall.8
Associate

The sad thing is that after more than two years (with CubeMx 6.5.0 and STM32G0 firmware package 1.5.0) this bug is still not fixed...