This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why is IRQ priority different in s140 SDS 1.2 and in app_util_platform.h ?

Hello,

While developing on the nRF52840, we noticed recently that the IRQ priorities that we find in app_util_platform.h (from SDK 15.2.0) differ from the ones we can see in S140_SDS_v1.2.pdf:

S140_SDS_v1.2.pdf page 83:

app_util_platform.h line 74:

#if __CORTEX_M == (0x00U)
[...]
#elif __CORTEX_M == (0x04U)
#define _PRIO_SD_HIGH 0
#define _PRIO_SD_MID 1
#define _PRIO_APP_HIGH 2
#define _PRIO_APP_MID 3
#define _PRIO_SD_LOW 4
#define _PRIO_SD_LOWEST 5
#define _PRIO_APP_LOW 6
#define _PRIO_APP_LOWEST 7
#define _PRIO_THREAD 15
#else
[...]

The main difference is that priority level 5 should be for the application, but on the code it's _PRIO_SD_LOWEST. Is this a mistake ? 

Also iif we look at the enum that comes right after:

typedef enum
{
#ifndef SOFTDEVICE_PRESENT
    APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH,
#else
    APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH,
#endif
    APP_IRQ_PRIORITY_HIGH    = _PRIO_APP_HIGH,
#ifndef SOFTDEVICE_PRESENT
    APP_IRQ_PRIORITY_MID     = _PRIO_SD_LOW,
#else
    APP_IRQ_PRIORITY_MID     = _PRIO_APP_MID,
#endif
    APP_IRQ_PRIORITY_LOW     = _PRIO_APP_LOW,
    APP_IRQ_PRIORITY_LOWEST  = _PRIO_APP_LOWEST,
    APP_IRQ_PRIORITY_THREAD  = _PRIO_THREAD     /**< "Interrupt level" when running in Thread Mode. */
} app_irq_priority_t;

We see that App_highest and App_high share the same level, since there are only 4 IRQ levels for the application. I guess that if level 5 was for the app as specified in the SDS, then they would be on two distinct levels. 

Is there an explanation for that ? And am I right to think that I should use the levels described in the SDS and not the ones I found in app_util_platform.h ? 

Related