Quality RTOS & Embedded Software

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


Loading

NVIC priority and FreeRTOS priority?

Posted by Thomas Johansen on November 21, 2012
Hi all

Hope someone can make me understand NVIC priority and FreeRTOS priority on Cortex M3 CPU's? (If that is possible :-))

From the FreeRTOS website:

"Therefore, any interrupt service routine that uses an RTOS API function must have its priority manually set to a value that is numerically equal to or greater than the configMAX_SYSCALL_INTERRUPT_PRIORITY setting."

My configMAX_SYSCALL_INTERRUPT_PRIORITY is defined to 40 ( 5 << (8 - configPRIO_BITS) )
I'm using CMSIS libary function NVIC_SetPriority(..) to set the NVIC priorities for interrupts.
The NVIC_SetPriority function does the shifting.

So which number must be greater or equal to configMAX_SYSCALL_INTERRUPT_PRIORITY
The value used in the NVIC_SetPriority function or the resulting priority???

I do have some ISR's calling xxxxGiveFromISR API function. So the NVIC priority set for those ISR'r must be set to more then 40?

As I understand a higher prio number on a Cortex M3 is equal to lower prioriy and in FreeRTOS it is higher?

Thomas

RE: NVIC priority and FreeRTOS priority?

Posted by Dave on November 21, 2012
Here is an example I just lifted from the new Atmel demo (I didn't choose the macro names!)

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions. DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY10


This defines configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY to be in a form acceptable to the NVIC_SetPriority function.


/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )




This uses the configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY definition to set configMAX_SYSCALL_INTERRUPT_PRIORITY in a form acceptable to the NVIC directly (which is how the FreeRTOS port layer uses it internally).

In this example, an interrupt that uses the FreeRTOS API has to have its priority set using the NVIC_SetPriority() function to a value of 10 or higher (so 10, 11, 12, etc).

(I also didn't design the Cortex-M3 NVIC mash up!)


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner