Quality RTOS & Embedded Software

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




Loading

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.

Regards.


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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists