STM32學習筆記(三)中斷配置和優先順序說明

2021-10-12 16:23:05 字數 4477 閱讀 3144

void nvic_prioritygroupconfig(uint32_t nvic_prioritygroup);

#define nvic_prioritygroup_0         ((uint32_t)0x700) 

/*!< 0 bits for pre-emption priority

4 bits for subpriority */

#define nvic_prioritygroup_1 ((uint32_t)0x600)

/*!< 1 bits for pre-emption priority

3 bits for subpriority */

#define nvic_prioritygroup_2 ((uint32_t)0x500)

/*!< 2 bits for pre-emption priority

2 bits for subpriority */

#define nvic_prioritygroup_3 ((uint32_t)0x400)

/*!< 3 bits for pre-emption priority

1 bits for subpriority */

#define nvic_prioritygroup_4 ((uint32_t)0x300)

/*!< 4 bits for pre-emption priority

0 bits for subpriority */

void nvic_init(nvic_inittypedef* nvic_initstruct);

typedef

struct

nvic_inittypedef;

==

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

== nvic_prioritygroup | nvic_irqchannelpreemptionpriority | nvic_irqchannelsubpriority | description

======

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

== nvic_prioritygroup_0 |0|

0-15|

0 bits for pre-emption priority

|||4 bits for subpriority

------

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

-- nvic_prioritygroup_1 |0-

1|0-

7|1 bits for pre-emption priority

|||3 bits for subpriority

------

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

--

nvic_prioritygroup_2 |0-

3|0-

3|2 bits for pre-emption priority

|||2 bits for subpriority

------

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

--

nvic_prioritygroup_3 |0-

7|0-

1|3 bits for pre-emption priority

|||1 bits for subpriority

------

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

----

--

nvic_prioritygroup_4 |0-

15|0|

4 bits for pre-emption priority

|||0 bits for subpriority

======

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

====

==

這個函式只需要呼叫一次,多次呼叫按照最後一次的引數執行

沒有組優先順序這種東西!!!!!!!!!!

nvic_irqchannelpreemptionpriority 搶占式優先順序

nvic_irqchannelsubpriority 響應式優先順序

第一條,高搶占式優先順序可以打斷低搶占式優先順序

第二條,相同搶占式優先順序之間,低響應式優先順序不會被打斷

stm32中斷優先順序 STM32中斷系統

stm32 中斷非常強大,幾乎每個外設都可以產生中斷,因此這裡我們單獨使用一章來介紹它,為後面介紹外設中斷做鋪墊。學習本章可以參考 stm32f10x中文參考手冊 9 中斷和事件章節,cortex m3 權威指南 中文 chpt08 nvic與中斷控制章節。中斷概念 在學習 51 微控制器時,我們就...

STM32中斷巢狀

cortex m3核心支援256個中斷,其中包括16個核心中斷和240個外部中斷,且具有256級的可程式設計中斷設定,而stm32只用了其中一部分。stm32有84個中斷,包括16個核心中斷和68個可遮蔽中斷,具有16級可程式設計中斷優先順序。而我所使用的103系列只有60個可遮蔽中斷。優先順序的判...

STM32 中斷使用

stm32中斷有時候用多了容易亂,特此記錄一下,因為之前一直是m3 m0交叉用,韌體庫有些區別容易弄混,這裡說一下m3外部中斷的配置 步驟 1.將對應的io配置為輸入 2.將io對應的中斷的優先等級用nvic配置好 3.設定好對應io的中斷模式和觸發方式 4.將io所屬的中斷線設為中斷輸入源 1 以...