Get current active interrupt priority

Hi everybody,

We are working on a simple priority RTC (run to completion) framework for the Cortex M3/M4. Thanks to the NVIC/BASEPRI, we got most of this functionality for free but we want to extend it to user tasks.

In our implementation we need to determine the current active interrupt priority to decide for: a) adjust BASEPRI for a higher priority task or b) Queue the request (like NVIC pending bit) to schedule it later

Does a NVIC/CPU register exist to directly get the current active interrupt priority? We havn't found any information in Yiu's book or on infocenter.arm.com.

Our current approce (in C) is:

IRQn_Type actirqn = ((int32_t)__get_IPSR()) - 16; /* -16 see IPSR bit assignments */
uint32_t actprio = actirqn==-16?PRIO_THREAD:NVIC_GetPriority(actirqn); /* Actual interrupt priority, PRIO_THREAD=0x100 for non IRQ prio */
uint32_t reqprio = task->priority; /* Requested interrupt priority */
/* ... */

We are thankful for any further hints.

Greetings

Jonathan

References:

Parents
  • Hello Jonathan,


    you can get the exception number of the current executing exception by the Interrupt Control and State Register (i.e. ICSR 0xE000ED04).
    I think from the current exception number, the current exception priority can be seen by System Handler Priority Register 1-3(i.e. SHPR1-3) or Interrupt Priority Registers (i.e. NVIC_IPR0-NVIC_IPR123).
    Isn't it your solution?

    Best regards,

    Yasuhiko Koumoto.

Reply
  • Hello Jonathan,


    you can get the exception number of the current executing exception by the Interrupt Control and State Register (i.e. ICSR 0xE000ED04).
    I think from the current exception number, the current exception priority can be seen by System Handler Priority Register 1-3(i.e. SHPR1-3) or Interrupt Priority Registers (i.e. NVIC_IPR0-NVIC_IPR123).
    Isn't it your solution?

    Best regards,

    Yasuhiko Koumoto.

Children
More questions in this forum