cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up an external interrupt

Gergo Tanyi
Associate II
Posted on June 06, 2018 at 13:42

Hi!

I found setting up an external interrupt in an STM32F103 to be a little bit hard. What is the sequence of to do's? I can find information fragments about the EXTI and NVIC, scattered through the reference manual and programming manual, while all I need is a few lines of hint what to do. Can somebody explain how to do it? I am not using any HAL, only CMSIS.

#external-interrupt #stm32-exti #nvic
5 REPLIES 5
AVI-crak
Senior
Posted on June 06, 2018 at 14:39

     SYSCFG-> EXTICR [2] = SYSCFG_EXTICR3_EXTI11_PD;

     EXTI-> RTSR | = EXTI_RTSR_TR11; // up front

     EXTI-> FTSR | = EXTI_FTSR_TR11; // the front on recession

     EXTI-> IMR | = EXTI_IMR_MR11; // set an interrupt mask

     sNVIC_EnableIRQ (EXTI15_10_IRQn, 14); // enable interrupts EXTI11

This is one of the simplest peripheral nodes in the chip. It works exactly as described in the documentation.

The interrupt is reset by writing a unit, the operator '| =' is not required !!!

Arman Ilmak
Senior
Posted on June 06, 2018 at 16:08

You can find this information in ST site in application notes section.

http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32f1-series/stm32f103/stm32f103c6.html

 
Posted on June 06, 2018 at 17:42

Thank you!

I completely forgot about these materials. But at the first glance on these resources, I haven't found anything on interrupts. I'll go over them more carefully later. 

Posted on June 06, 2018 at 22:38

Avi's post appears to contain the complete guide (after setting clocks and perhaps not setting GPIOs as Analog), except that the EXTI mux on the slightly ancient 'F1xx is in AFIO (which also needs to enable clock) rather than SYSCFG.

JW

Posted on June 08, 2018 at 14:06

Yep it works, and very easy once you know how it works and what to do. But when you do it the firs time, it's not as obvious and the EXTI mux is indeed in AFIO registers in th F1xx series. Thanks! .