# NVIC User Interrupt Priority

**URL:** <https://forums.freertos.org/t/nvic-user-interrupt-priority/7210>\
**Category:** Kernel\
**Created:** [May 22, 2018, 4:43pm UTC](https://forums.freertos.org/t/nvic-user-interrupt-priority/7210 "2018-05-22T16:43:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 22, 2018, 4:43pm UTC](https://forums.freertos.org/t/nvic-user-interrupt-priority/7210/1 "2018-05-22T16:43:33Z")

</div>

**[ammannlu](https://sourceforge.net/u/ammannlu/)** wrote on [Tuesday, May 22, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/301f88c7/#72fc):

Hi

Im using FreeRTOX V9.0.0 on a Cortex M3 (Silicon Labs EFM32GG380F1024).  
I get a assert failure when i use the TaskResumeFromISR via the GPIO Irq Handler.

The assert fails here in port.c (GCC ARM CM3) in function “void vPortValidateInterruptPriority( void )”  
on line “configASSERT( ucCurrentPriority \>= ucMaxSysCallPriority );”  
The values are: ucCurrentPriority is 0 and ucMaxSysCallPriority is 160.

```auto
// NVIC CORTEX M3
#define configPRIO_BITS 3

// FreeRTOS Config
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ( 0x05 )
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

// port.c
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue; // ( ( 0x05 ) << (8 - ( 3 )) ) & 224 = 160

```

In the user code, when i read the interrupt priority (where i currently use default “0”) i get all interrupt priorities are zero except the 2  
that are set up by the kernel (PendSV and Systick) which are 7.

```auto
// user code
prio = hal::nvic::getPriority(NonMaskableInt_IRQn); // =0
prio = hal::nvic::getPriority(HardFault_IRQn); // =0
prio = hal::nvic::getPriority(MemoryManagement_IRQn); // =0
prio = hal::nvic::getPriority(BusFault_IRQn); // =0
prio = hal::nvic::getPriority(UsageFault_IRQn); // =0
prio = hal::nvic::getPriority(SVCall_IRQn); // =0
prio = hal::nvic::getPriority(DebugMonitor_IRQn); // =0
prio = hal::nvic::getPriority(PendSV_IRQn); // =7
prio = hal::nvic::getPriority(SysTick_IRQn); // =7
prio = hal::nvic::getPriority(GPIO_EVEN_IRQn); // =0
prio = hal::nvic::getPriority(GPIO_ODD_IRQn); // =0
prio = hal::nvic::getPriority(USART1_RX_IRQn); // =0
prio = hal::nvic::getPriority(USART1_TX_IRQn); // =0
prio = hal::nvic::getPriority(LETIMER0_IRQn); // =0
prio = hal::nvic::getPriority(RTC_IRQn); // =0
prio = hal::nvic::getPriority(BURTC_IRQn); // =0

```

As soon as i define my interrupt priority 7 or higher, i have no more trouble.

When i now define each priority for each interrupt, what values can i use (where lower is higher priority and i should go bigger  
than 7 since my interrupts should have lower prio than the kernel).

So should i start at 8 and go up until where??

Thank you

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 22, 2018, 4:52pm UTC](https://forums.freertos.org/t/nvic-user-interrupt-priority/7210/2 "2018-05-22T16:52:55Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, May 22, 2018](https://sourceforge.net/p/freertos/discussion/382005/thread/301f88c7/#72fc/61f5):

Generally your interrupts should have equal or higher priority than the  
kernel - and the kernel should have the lowest possible priority (in  
most cases) - hence you can’t go lower than the kernel.

Assuming the setting of configPRIO\_BITS is correct (if you use FreeRTOS  
V10.0.1 and have configASSERT() defined then that will get checked  
automatically), and configLIBRARY\_MAX\_SYSCALL\_INTERRUPT\_PRIORITY is set  
to 5, then interrupt priorities with a numeric value equal to or greater  
than 5 (meaning the interrupt has a logical priority equal to or lower  
than 5) are fine. Hence when you set 7 you do not get a problem.
