NVIC Priority Calculator
Preempt / subpriority split from PRIGROUP, for Cortex-M NVIC interrupt priorities.
Selected grouping
Preempt bits
–
Sub bits
–
Preempt levels
–
Sub levels
–
Encoded priority field
–
8-bit register value
–
All PRIGROUP values
| PRIGROUP | Preempt bits | Sub bits | Preempt levels | Sub levels |
|---|
How it works
Cortex-M splits each interrupt's implemented priority bits into a preempt
group (can interrupt a lower preempt priority mid-handler) and a subpriority
(only orders pending interrupts of equal preempt priority). PRIGROUP (in
SCB->AIRCR) decides the split:
preempt bits = min(7 − PRIGROUP, N) sub bits = N − preempt bits
where N is the number of priority bits the silicon actually implements
(__NVIC_PRIO_BITS, 4 on most STM32 parts). The priority value passed to
NVIC_SetPriority() occupies the top N bits of the 8-bit priority
register field, so it is left-shifted by 8 − N.