STM32(Cortex-M3)中有兩個優先級的概念——搶占式優先級和響應優先級,有人把響應優先級稱作'亞優先級'或'副優先級(有關這個概念在下面附加內容有)',每個中斷源都需要被指定這兩種優先級。
具有高搶占式優先級的中斷可以在具有低搶占式優先級的中斷處理過程中被響應,即中斷嵌套,或者說高搶占式優先級的中斷可以嵌套低搶占式優先級的中斷。
當兩個中斷源的搶占式優先級相同時,這兩個中斷將沒有嵌套關系,當一個中斷到來后,如果正在處理另一個中斷,這個后到來的中斷就要等到前一個中斷處理完之后才能被處理。如果這兩個中斷同時到達,則中斷控制器根據他們的響應優先級高低來決定先處理哪一個;如果他們的搶占式優先級和響應優先級都相等,則根據他們在中斷表中的排位順序決定先處理哪一個。
The PRIGROUP field indicates the position of the binary point that splits the PRI_n fields in the Interrupt
Priority Registers into separate group priority and subpriority fields. Table 4.18 (p. 100) shows how
the PRIGROUP value controls this split.
Table 4.18. Priority grouping
Interrupt priority level value, PRI_N[7:0] Number of Number of
PRIGROUP Binary point Group priority bits Subpriority bits Group priorities Subpriorities
b100-b000 bxxx.00000 [7:5] None 8 1
b101 bxx.y00000 [7:6] [5] 4 2
b110 bx.yy00000 [7] [6:5] 2 4
b111 b.yyy00000 None [7:5] 1 8
1PRI_n[7:0] field showing the binary point. x denotes a group priority field bit, and y denotes a subpriority field bit.