2020-02-10 07:55 AM
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;
Solved! Go to Solution.
2020-11-04 01:25 AM
Hello @Simon Sq ,
The proposal fix is to add the following code "uwTickPrio = TickPriority;" in stm32f4xx_hal_timebase_tim.c file before this line:
HAL_NVIC_SetPriority(TIM7_IRQn, TickPriority ,0); under /*Configure the TIM7 IRQ priority */
I'm checking with the development team on the status of this issue.
Our apologies for the delay.
Imen
2020-02-13 12:30 AM
Hello @OGhis ,
Thanks for your contribution and reported issue.
Can you please share your ioc file for check the project settings and configuration. So, that it will be easier for us to reproduce the issue.
Best Regards,
Imen
2020-02-15 07:27 AM
2020-03-02 11:39 AM
Not yet resolved in HAL lib V 1.2.0 of the STM32G4
2020-03-02 11:48 AM
for library version 1.2.0 for the STM32G4:
Cannot understand why there is an external decalation of the uint32_t uwTickPrio; ==> there is a function uint32_t HAL_GetTickPrio(void) to get the result of the uwTickPrio.
2020-04-12 09:33 PM
I hit the same issue and took me a while to debug. The problem will also show up when you enable -DUSE_FULL_ASSERT on the FreeRTOS, ThreadCreate example.
All stm32**xx_hal_timebase_tim.c will have a line
HAL_NVIC_SetPriority(TIM1_TRG_COM_TIM17_IRQn, TickPriority, 0), where TickPriority = 1 << 4 => 16.
and in the stm32**xx_hal_cortex.c
void HAL_NVIC_SetPriority() function will check
assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority)). This line check if the priority is less than 16. and of course, 16 is not less then 16 so it asserted if you enable the assertion.
Still not fixed?
Tony
2020-04-12 11:03 PM
I think uwTickPrio is the storage for the HAL library to get the tick priority when necessary. It's a variable initialized with an invalid value (16). Since HAL_INIT is (should be) the first function to call. Inside the HAL_INIT, it will initialized the tick priority according to TICK_INT_PRIO at the stm32_hal_conf.h by calling HAL_InitTick().
The problem here is that the function HAL_InitTick() in stm32**xx_hal_timebase_tim.c, There should add a line
uwTickPrio = TickPriority; after the HAL_NVIC_SetPriority(). so the uwTickPrio will be set to correct value.
Tony
2020-04-13 09:14 AM
IIRC this was already reported for CubeMX templates in other STM32 family. And fixed.
-- pa
2020-08-04 01:27 AM
The issue is still not fixed. CubeMX 6.0.0.
2020-08-04 02:16 AM
Hello @DUlia ,
There is a major issue related to STM32CubeMX 6.0.0: IRQ preemption priorities are set to 0 after project migration.
The correction is ongoing for this issue.
Thank you for your understand.
Best Regards,
Imen