NVIC User Interrupt Priority
Posted by
ammannlu on 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 configLIBRARYMAXSYSCALLINTERRUPTPRIORITY ( 0x05 )
define configKERNELINTERRUPTPRIORITY ( configLIBRARYLOWESTINTERRUPTPRIORITY << (8 – configPRIOBITS) )
define configMAXSYSCALLINTERRUPTPRIORITY ( configLIBRARYMAXSYSCALLINTERRUPTPRIORITY << (8 – configPRIOBITS) )
// port.c
ucMaxSysCallPriority = configMAXSYSCALLINTERRUPT_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(NonMaskableIntIRQn); // =0
prio = hal::nvic::getPriority(HardFaultIRQn); // =0
prio = hal::nvic::getPriority(MemoryManagementIRQn); // =0
prio = hal::nvic::getPriority(BusFaultIRQn); // =0
prio = hal::nvic::getPriority(UsageFaultIRQn); // =0
prio = hal::nvic::getPriority(SVCallIRQn); // =0
prio = hal::nvic::getPriority(DebugMonitorIRQn); // =0
prio = hal::nvic::getPriority(PendSVIRQn); // =7
prio = hal::nvic::getPriority(SysTickIRQn); // =7
prio = hal::nvic::getPriority(GPIOEVENIRQn); // =0
prio = hal::nvic::getPriority(GPIOODDIRQn); // =0
prio = hal::nvic::getPriority(USART1RXIRQn); // =0
prio = hal::nvic::getPriority(USART1TXIRQn); // =0
prio = hal::nvic::getPriority(LETIMER0IRQn); // =0
prio = hal::nvic::getPriority(RTCIRQn); // =0
prio = hal::nvic::getPriority(BURTCIRQn); // =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
NVIC User Interrupt Priority
Posted by
rtel on 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 configPRIOBITS is correct (if you use FreeRTOS
V10.0.1 and have configASSERT() defined then that will get checked
automatically), and configLIBRARYMAXSYSCALLINTERRUPT_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.