cancel
Showing results for 
Search instead for 
Did you mean: 

(Bug Report) SysTick NVIC priority is incorrectly configured at the initialization code

THA.1
Associate II

(Environment)

MC_SDK 5.Y.3 + STM32CubeMX 6.3.0 + IAR EWARM 8.5

(Hardware)

NUCLEO-F446RE + X-NUCLEO-IHM08M1 + Low Voltage BLDC motor

(What I found)

  • By CubeMX, SysTick NVIC priority is configured as Priority Group=3bit+1bit, PreemptPriority=4, SubPriority=0
  • At main(), HAL_Init() and SystemClock_Config() implement the above configuration, then I can read the same values for their registers.
  • Right after the above code, however, MX_MotorControl_Init() calls HAL_SYSTICK_Config(), where SysTick priority is set to 15, PreemptPriority=7, SubPriority=1

(Question)

  • Is that a defect or am I doing something wrong in configuration & code generation?
  • If a defect, is it good enough to add HAL_NVIC_SetPriority() for SysTick in MX_MotorContorl_Init()?
  • Or removing NVIC_SetPriority() in SysTick_Config() would be better?

SysTick initialization code looks a little messy.

1 ACCEPTED SOLUTION

Accepted Solutions
cedric H
ST Employee

Hello @THA.1​ ,

You are right, the MX_MotorControl_Init() overwrites the SysTick priority, and this is a bug.

If you generate with HAL, you could replace the following line in MX_MotorControl_Init(void) :

 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/SYS_TICK_FREQUENCY);

by this one :

HAL_SetTickFreq(HAL_RCC_GetHCLKFreq()/SYS_TICK_FREQUENCY);

Doing this will restore the SYSTick interrupt level set by HAL_Init(), and this is what we want.

Thanks for reporting.

Please note that the strategy for the systick is to be the lowest priority compared to other interrupts. As by default the MX_MotorControl_INIT() reset it to the lowest possible value, we did not catch it.

We advice our users who want to use another interrupt for there own application to set its priority level under the one of Systick, which is not possible due to this bug. We plan to fix it in the next release.

Regards

Cedric

View solution in original post

3 REPLIES 3
cedric H
ST Employee

Hello @THA.1​ ,

You are right, the MX_MotorControl_Init() overwrites the SysTick priority, and this is a bug.

If you generate with HAL, you could replace the following line in MX_MotorControl_Init(void) :

 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/SYS_TICK_FREQUENCY);

by this one :

HAL_SetTickFreq(HAL_RCC_GetHCLKFreq()/SYS_TICK_FREQUENCY);

Doing this will restore the SYSTick interrupt level set by HAL_Init(), and this is what we want.

Thanks for reporting.

Please note that the strategy for the systick is to be the lowest priority compared to other interrupts. As by default the MX_MotorControl_INIT() reset it to the lowest possible value, we did not catch it.

We advice our users who want to use another interrupt for there own application to set its priority level under the one of Systick, which is not possible due to this bug. We plan to fix it in the next release.

Regards

Cedric

cedric H
ST Employee

Sorry, I answered to fast,

HAL_SetTickFreq does the job, but the prototype is not the right one.

I come back after additional tests.

Cedric

Thank you!

I would be able to manage this before the next release :)