Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT


SysTick interrupt priority

Posted by samfpetersen on January 6, 2016

I'm using FreeRTOS V8.2.1 on STM32F4 and my question is about the SysTick interrupt priority. The FreeRTOS source says that it should be the "lowest priority interrupt", and it explicitly sets it to the lowest priority in xPortStartScheduler(). This seems backwards to me, shouldn't it be the highest?

Further complicating things is the STM32's HAL libraries, which have their own systick implementation... It specifies that you should set the systick interrupt to the highest priority.

By the way, I'm referring to logically highest not numerically highest, and I'm aware that they are inverted

Thanks, Sam

SysTick interrupt priority

Posted by rtel on January 6, 2016

The interrupt that absolutely must be the lowest priority is the PendSV interrupt. The SysTick interrupt could be higher, but could interfer with application interrupts if it is.

When the ST HAL is used with FreeRTOS, like it can be with the STM32 Cube software supplied by ST, then ST call the FreeRTOS tick handler from their HAL tick handler. That means you must not install the FreeRTOS handler. However, I do it the other way around - installing the FreeRTOS handler as normal, then calling the HAL tick handler from the FreeRTOS tick hook function.


SysTick interrupt priority

Posted by rtel on January 7, 2016

Actually - I would like to correct my previous post. The SysTick handler does need to run at the lowest priority. This is because the critical section within the handler itself assumes it is running at the lowest priority, so saves time by not saving the old priority mask and then restoring the previous priority mask.

SysTick interrupt priority

Posted by samfpetersen on January 8, 2016

The conflict I encounter is that the ST HAL SysTick must be at the highest priority, since there are HAL layer ISRs that wait on a timeout (which is bad, but it is what it is). So to fix this, I'm setting the SysTick interrupt to the highest priority, and in that ISR I'm calling the ST HAL tick function and setting another interrupt at the lowest priority. In the ISR of that interrupt, I'm calling the FreeRTOS tick function.

Seems hacky, but I can't think of a better way to do this at the moment. Thoughts?

Thanks, Sam

SysTick interrupt priority

Posted by janoshnosh on November 9, 2016

@Sam Petersen I totally agree with that strategy. I have no understanding for why the SysTick interrupt should be of lowest priority. In my opinion, FreeRTOS wouldn't have anything to do with a real-time system anymore, if it doesn't keep counting milliseconds. We have the same issue here, that the HAL-ISR-delays make all time calculations based on the FreeRTOS tick invalid. And ridiculous.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS