STM32(Cortex-M3)中有兩個(gè)優(yōu)先級的概念——搶占式優(yōu)先級和響應(yīng)優(yōu)先級,有人把響應(yīng)優(yōu)先級稱作'亞優(yōu)先級'或'副優(yōu)先級(有關(guān)這個(gè)概念在下面附加內(nèi)容有)',每個(gè)中斷源都需要被指定這兩種優(yōu)先級。
具有高搶占式優(yōu)先級的中斷可以在具有低搶占式優(yōu)先級的中斷處理過程中被響應(yīng),即中斷嵌套,或者說高搶占式優(yōu)先級的中斷可以嵌套低搶占式優(yōu)先級的中斷。
當(dāng)兩個(gè)中斷源的搶占式優(yōu)先級相同時(shí),這兩個(gè)中斷將沒有嵌套關(guān)系,當(dāng)一個(gè)中斷到來后,如果正在處理另一個(gè)中斷,這個(gè)后到來的中斷就要等到前一個(gè)中斷處理完之后才能被處理。如果這兩個(gè)中斷同時(shí)到達(dá),則中斷控制器根據(jù)他們的響應(yīng)優(yōu)先級高低來決定先處理哪一個(gè);如果他們的搶占式優(yōu)先級和響應(yīng)優(yōu)先級都相等,則根據(jù)他們在中斷表中的排位順序決定先處理哪一個(gè)。
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.