cancel
Showing results for 
Search instead for 
Did you mean: 

Value of TICK_INT_PRIORITY (default value changed)

LKett.1
Associate II

I have a question about the value of `TICK_INT_PRIORITY` in a project for the STM32G070CBT6. I am not using FreeRTOS (which I think makes a difference here), and all projects have been created with the (default) `Targeted Language`: `C`, `Targeted Binary Type`: `Executable` and `Targeted Project Type`: `STM32Cube` options selected.

I was trying to change the MCU used for a project from using an STM32G030C8T6, and couldn't find a way to do that without starting with a new project and bringing the older code into it. But between making the original STM32G030C8T6-based project and the new STM32G070CBT6-based one, I've gone through several changes in the STM32CubeIDE, too (and the old version has been migrated through these from the version it was originally created in).

Something I noticed, as I was comparing files to make sure I'd moved all of the code and settings across), was that the value set for `TICK_INT_PRIORITY` in a `#define`, in file `stm32g0xx_hal_conf.h`, was `3U` in the new project, but `0U` in the old project.

If I make a new project for either the STM32G030C8T6 or the STM32G070CBT6 in the new version of the IDE (`Version: 1.11.0, Build: 13638_20221122_1308 (UTC)`), it gives me a default value of `3U`.

That doesn't seem to be changeable directly in that file, as a change to / save of the `.ioc` file (via STM32CubeMX) changes the value back to `3U` again. It seems to be settable in the value after the `Time base: System tick timer` option, in the `System Core`, `NVIC`, `NVIC` (tab), `NVIC Interrupt Table` section, under the `Pinout & Configuration` main tab, though.

It seems like the value of `TICK_INT_PRIORITY` might be important for ensuring that the "source of the time base" is maintained, and incremented every 1 ms (though I may well be misunderstanding this), and it states in comments above the function definition for `HAL_InitTick()` that "In the default implementation, SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Care must be taken if HAL_Delay() is called from a peripheral ISR process, The SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked."

Presumably that is why it was set to `0U` in the original default projects I created (some time ago), but it is not clear why that has now been changed to a value of `3U`?

I have had a look around, but there is not much about this value, so I was wondering if anyone can shed any light on what is the best value for `TICK_INT_PRIORITY`, and why its default was changed from `0U` to `3U`?

I also noticed that this post asked if there was a way to change the value in STM32CubeMX, and it was stated that there was not a way:

[sorry, I tried to embed a link here, but can't as a new member - the post title was "Is there a setting with STM32CubeMX to change the Tick Init Priority / TICK_INT_PRIORITY value?"]

But that was a couple of years ago, so maybe this is a new(ish) addition (to the MX part of the IDE)?

Thank you for any help you can give.

1 ACCEPTED SOLUTION

Accepted Solutions
Piranha
Chief II

The HAL timebase tick interrupt priority must be higher than the priority of any other interrupt, from which any of the HAL API functions are called.

As for the parody of forum... In this SalesForce junk the only options are basic text formatting and Code Snippet for blocks of code.

View solution in original post

3 REPLIES 3
LKett.1
Associate II

P.S. Sorry, I thought that the backticks might be picked up as inline code (monospaced font on the same line as the preceding and succeeding text), as they are in so many other interfaces, but from what I can see it doesn't seem possible to render anything other than full lines of code. What do people do here, use bold or italics?

Piranha
Chief II

The HAL timebase tick interrupt priority must be higher than the priority of any other interrupt, from which any of the HAL API functions are called.

As for the parody of forum... In this SalesForce junk the only options are basic text formatting and Code Snippet for blocks of code.

LKett.1
Associate II

Thank you for your advice.

I guess if I make it `0U` priority, it'll match the other projects I have, and should be at least as high a priority as anything else. Seems odd that something fundamental like that would need to change between IDE versions.