Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
stm32:peripherals:exti [2019/09/16 07:24] – [Setup Peripheral (e.g. GPIOA Pin 5)] kjazstm32:peripherals:exti [2022/12/28 08:29] (current) – [SYSCFG_EXTICR4 - External interrupt configuration register 4] ruan
Line 18: Line 18:
 \\ \\
  
-===== Programming Example ===== 
  
-==== Setup Peripheral (e.g. GPIOA Pin 5) ==== 
- 
-<code c> 
-#include "reg_stm32f4xx.h" 
- 
-RCC->AHB1ENR |= (0x1 << 0u);    /* Enable GPIOA clock */ 
- 
-/* Configure GPIO pin A.5 as input. */ 
-GPIOA->MODER &= ~(0x3 << 10u);    /* Clear existing mode bits 10 and 11. */ 
- 
-GPIOA->PUPDR &= ~(0x3 << 10u);    /* Clear existing pull-up/-down bits 10 and 11. */ 
-GPIOA->PUPDR |= (0x1 << 10u);     /* Set pin 5 to pull-up mode. */ 
-</code> 
-\\ 
- 
-==== Setup SYSCFG ==== 
- 
-To choose which GPIO peripheral should trigger EXTI line 5 you have to configure the SYSCFG register. 
- 
-<code c> 
-#include "reg_stm32f4xx.h" 
- 
-SYSCFG->EXTICR[1] |= (0u << 4u);  /* Set EXTI5 to GPIOA. */ 
-</code> 
-\\ 
- 
-==== Setup EXTI ==== 
- 
-<code c> 
-#include "reg_stm32f4xx.h" 
- 
-EXTI->RTSR |= (0x1 << 5u);         /* Trigger on rising edge. */ 
-EXTI->IMR |= (0x1 << 5u);          /* Unmask interrupt line. */ 
-</code> 
-\\ 
- 
-==== Setup NVIC ==== 
- 
-<code c> 
-#include "reg_stm32f4xx.h" 
- 
-NVIC->ISER[0] |= (0x1 << 23u);     /* Enable EXTI5 interrupt. */ 
-</code> 
-\\ 
  
 ===== Configuration Register ===== ===== Configuration Register =====
  
-==== SYSCFG EXTICRx ==== +==== SYSCFG_EXTICR1 - External interrupt configuration register 1 ====
- +
-=== EXTICR1 === +
- +
-External interrupt configuration register 1+
  
 \\ {{syscfg_reg_exticr1.svg}} \\ \\ \\ {{syscfg_reg_exticr1.svg}} \\ \\
  
-=== EXTICR2 === +==== SYSCFG_EXTICR2 - External interrupt configuration register 2 ====
- +
-External interrupt configuration register 2+
  
 \\ {{syscfg_reg_exticr2.svg}} \\ \\ \\ {{syscfg_reg_exticr2.svg}} \\ \\
  
-=== EXTICR3 === +==== SYSCFG_EXTICR3 - External interrupt configuration register 3 ====
- +
-External interrupt configuration register 3+
  
 \\ {{syscfg_reg_exticr3.svg}} \\ \\ \\ {{syscfg_reg_exticr3.svg}} \\ \\
  
-=== EXTICR4 === +==== SYSCFG_EXTICR4 - External interrupt configuration register 4 ====
- +
-External interrupt configuration register 4+
  
 \\ {{syscfg_reg_exticr4.svg}} \\ \\ \\ {{syscfg_reg_exticr4.svg}} \\ \\
  
 +Select the source input for EXTI
 |< 100% 5em 5em >| |< 100% 5em 5em >|
 |EXTIx|0000|GPIOA pin x (reset state)| |EXTIx|0000|GPIOA pin x (reset state)|
Line 100: Line 46:
 \\ \\
  
-==== EXTI - RTSR FTSR ==== +==== EXTI_RTSR EXTI_FTSR Rising / falling trigger selection register ====
- +
-Rising / falling trigger selection register+
  
 \\ {{exti_reg_xtsr.svg}} \\ \\ \\ {{exti_reg_xtsr.svg}} \\ \\
Line 111: Line 55:
 \\ \\
  
-==== EXTI IMR ==== +==== EXTI_IMR Interrupt mask register ====
- +
-Interrupt mask register+
  
 \\ {{exti_reg_imr.svg}} \\ \\ \\ {{exti_reg_imr.svg}} \\ \\
Line 122: Line 64:
 \\ \\
  
-==== EXTI PR ==== +==== EXTI_PR Pending register ====
- +
-Pending register+
  
 \\ {{exti_reg_pr.svg}} \\ \\ \\ {{exti_reg_pr.svg}} \\ \\
Line 132: Line 72:
 |:::|1|Selected trigger request occured| |:::|1|Selected trigger request occured|
 * This bit is set when the selected edge event arrives on the external interrupt line x. This bis is cleared by programming it to '1' * This bit is set when the selected edge event arrives on the external interrupt line x. This bis is cleared by programming it to '1'
 +
 +===== Programming Example =====
 +
 +==== Setup Peripheral (e.g. GPIOA Pin 5) ====
 +
 +<code c>
 +#include "reg_stm32f4xx.h"
 +
 +RCC->AHB1ENR |= (0x1 << 0u);    /* Enable GPIOA clock */
 +
 +/* Configure GPIO pin A.5 as input. */
 +GPIOA->MODER &= ~(0x3 << 10u);    /* Clear existing mode bits 10 and 11. */
 +
 +GPIOA->PUPDR &= ~(0x3 << 10u);    /* Clear existing pull-up/-down bits 10 and 11. */
 +GPIOA->PUPDR |= (0x1 << 10u);     /* Set pin 5 to pull-up mode. */
 +</code>
 +\\
 +
 +==== Setup SYSCFG ====
 +
 +To choose which GPIO peripheral should trigger EXTI line 5 you have to configure the SYSCFG register.
 +
 +<code c>
 +#include "reg_stm32f4xx.h"
 +
 +SYSCFG->EXTICR2 |= (0u << 4u);  /* Set EXTI5 to GPIOA. */
 +</code>
 +\\
 +
 +==== Setup EXTI ====
 +
 +<code c>
 +#include "reg_stm32f4xx.h"
 +
 +EXTI->RTSR |= (0x1 << 5u);         /* Trigger on rising edge. */
 +EXTI->IMR |= (0x1 << 5u);          /* Unmask interrupt line. */
 +</code>
 +\\
 +
 +==== Setup NVIC ====
 +
 +<code c>
 +#include "reg_stm32f4xx.h"
 +
 +NVIC->ISER0 |= (0x1 << 23u);     /* Enable EXTI5 interrupt. */
 +</code>
 +\\
  
  • stm32/peripherals/exti.1568618646.txt.gz
  • Last modified: 2019/09/16 07:24
  • by kjaz