STM32L152 外部中斷配置

2021-07-12 06:17:25 字數 3579 閱讀 2788

外部中斷0,管腳為pa0為例來進行配置

void sys_exti0init(void)

中斷服務子程式的函式名是已經定義好了,在韌體庫中中斷檔案中這樣子說明:

在startup_stm32l1xx_mdp.s 檔案中,中斷函式名如下定義:

; external interrupts

dcd wwdg_irqhandler ; window watchdog

dcd pvd_irqhandler ; pvd through exti line detect

dcd tamper_stamp_irqhandler ; tamper and time stamp

dcd rtc_wkup_irqhandler ; rtc wakeup

dcd flash_irqhandler ; flash

dcd rcc_irqhandler ; rcc

dcd exti0_irqhandler ; exti line

0 dcd exti1_irqhandler ; exti line

1 dcd exti2_irqhandler ; exti line

2 dcd exti3_irqhandler ; exti line

3 dcd exti4_irqhandler ; exti line

4 dcd dma1_channel1_irqhandler ; dma1 channel 1

dcd dma1_channel2_irqhandler ; dma1 channel 2

dcd dma1_channel3_irqhandler ; dma1 channel 3

dcd dma1_channel4_irqhandler ; dma1 channel 4

dcd dma1_channel5_irqhandler ; dma1 channel 5

dcd dma1_channel6_irqhandler ; dma1 channel 6

dcd dma1_channel7_irqhandler ; dma1 channel 7

dcd adc1_irqhandler ; adc1

dcd usb_hp_irqhandler ; usb high priority

dcd usb_lp_irqhandler ; usb low priority

dcd dac_irqhandler ; dac

dcd comp_irqhandler ; comp through exti line

dcd exti9_5_irqhandler ; exti line

9..5

dcd lcd_irqhandler ; lcd

dcd tim9_irqhandler ; tim9

dcd tim10_irqhandler ; tim10

dcd tim11_irqhandler ; tim11

dcd tim2_irqhandler ; tim2

dcd tim3_irqhandler ; tim3

dcd tim4_irqhandler ; tim4

dcd i2c1_ev_irqhandler ; i2c1 event

dcd i2c1_er_irqhandler ; i2c1 error

dcd i2c2_ev_irqhandler ; i2c2 event

dcd i2c2_er_irqhandler ; i2c2 error

dcd spi1_irqhandler ; spi1

dcd spi2_irqhandler ; spi2

dcd usart1_irqhandler ; usart1

dcd usart2_irqhandler ; usart2

dcd usart3_irqhandler ; usart3

dcd exti15_10_irqhandler ; exti line

15..10

dcd rtc_alarm_irqhandler ; rtc alarm through exti line

dcd usb_fs_wkup_irqhandler ; usb fs wakeup from suspend

dcd tim6_irqhandler ; tim6

dcd tim7_irqhandler ; tim7

dcd 0 ; reserved

dcd tim5_irqhandler ; tim5

dcd spi3_irqhandler ; spi3

dcd 0 ; reserved

dcd 0 ; reserved

dcd dma2_channel1_irqhandler ; dma2 channel 1

dcd dma2_channel2_irqhandler ; dma2 channel 2

dcd dma2_channel3_irqhandler ; dma2 channel 3

dcd dma2_channel4_irqhandler ; dma2 channel 4

dcd dma2_channel5_irqhandler ; dma2 channel 5

dcd aes_irqhandler ; aes

dcd comp_acq_irqhandler ; comparator channel acquisition

使用上面的對應的中斷函式名來編寫相對應的程式

STM32配置外部中斷

stm32 中斷非常強大,每個外設都可以產生中斷,核心水平上搭載了乙個異常響應系統,分為 系統異常和外部中斷。nvic相當於乙個中斷總開關,總開關開啟,相應的中斷才能使用。在講如何配置中斷優先順序之前,我們需要先了解下 nvic。nvic 是巢狀向量中斷控制 器,控制著整個晶元中斷相關的功能,是核心...

stm32外部中斷配置步驟

外部中斷配置步驟 初始化io口為復用 afio void gpio init gpio typedef gpiox,gpio inittypedef gpio initstruct 開啟io口復用時鐘 void rcc apb2periphclockcmd uint32 t rcc apb2peri...

stm32外部中斷的配置

void user exit init void exti0 irqhandler 需要在main函式中設定中斷優先組 nvic prioritygroupconfig nvic prioritygroup 1 void userexitinit void exti0 irqhandler 同樣也需...