(Bug Report) SysTick NVIC priority is incorrectly configured at the initialization code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-14 2:14 AM
(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.
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-15 2:09 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-15 2:09 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-15 2:22 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-15 10:03 PM
Thank you!
I would be able to manage this before the next release :)
