We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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:
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.
Hi Mr. Koumoto
It's more or less the same, we us the IPSR (part of the Program Status Register PSR) to get the active ISR_NUMBER and then lookup in SHPRx and NVIC_IPRxxx for the programmed priority.
We hoped there exist a short-cut to get the current active priority directly to save some core cycle
Thanks for looking into it