NVIC priority and FreeRTOS priority?

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

NVIC priority and FreeRTOS priority?

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_PRIORITY    10
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!)