NVIC User Interrupt Priority

ammannlu wrote on Tuesday, May 22, 2018:

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.

// 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.

// 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

rtel wrote on Tuesday, May 22, 2018:

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.