当前位置:网站首页>Stm32f407 key interrupt
Stm32f407 key interrupt
2022-07-03 09:52:00 【0725 you Guangchuan】

Configure the register through the figure above , Yes 23 External interrupts are shown below 
According to external interrupt ,9 System configuration controller (SYSCFG) Chapter of ,SYSCFG external interrupt configuration register 1(SYSCFG_EXTICR1~4) Configure interrupt source and pin ,
See the reference manual for relevant interruptions SYSCFG And interruptions and events 、Core_m4 NVIC Chapter of
1、 Steps to configure key interrupts
(1) To configure PA0 and PC13 Of GPIO Pin type mode
(2) Configure in SYSCFg Interrupt source and pin
(3) Enable the associated clock ,(GPIO and SYSCFG)
(4)/* choice EXTI Interrupt source */
(5) Configure nested vector interrupt controller NVIC
The programming is as follows 、
#include “ygcKeyItr.h”
void ygcNVIC_Configuration()
{
NVIC_InitTypeDef NVIC_InitStruct;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStruct.NVIC_IRQChannel=EXTI0_IRQn;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0;
NVIC_InitStruct.NVIC_IRQChannelSubPriority=1;
NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStruct);
NVIC_InitStruct.NVIC_IRQChannel=EXTI15_10_IRQn;
NVIC_Init(&NVIC_InitStruct);
}
void ygcEXTI_Key_Config(void)
{
/ Define a GPIO_InitTypeDef Type of structure /
GPIO_InitTypeDef GPIO_InitStructure;
// Can make GPIO The clock
RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOC,ENABLE);
// To configure PA0 and PC13 Input mode pin
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
// timing PC13 Pin
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;
GPIO_Init(GPIOC, &GPIO_InitStructure);
// Can make SYSCFG The clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Connect EXTI Interrupt source To key1 Pin /
SYSCFG_EXTILineConfig( EXTI_PortSourceGPIOA, EXTI_PinSource0);
/ Connect EXTI Interrupt source To key2 Pin */
SYSCFG_EXTILineConfig( EXTI_PortSourceGPIOC, EXTI_PinSource13);
/* Initialize interrupt source */
EXTI_InitTypeDef EXTI_InitStruct;
EXTI_InitStruct.EXTI_Line=EXTI_Line0;// External interrupt channel PA0
EXTI_InitStruct.EXTI_Mode=EXTI_Mode_Interrupt;
EXTI_InitStruct.EXTI_Trigger=EXTI_Trigger_Rising;
EXTI_InitStruct.EXTI_LineCmd=ENABLE;
EXTI_Init(&EXTI_InitStruct);
EXTI_InitStruct.EXTI_Line=EXTI_Line13; External interrupt channel PC13
EXTI_Init(&EXTI_InitStruct);
/* The third step : To configure NVIC */
ygcNVIC_Configuration();
/* Configure interrupt function */
}
void EXTI0_IRQHandler(void)//PA0 Interrupt function
{
// Make sure that... Is generated EXTI Line interrupt
if(EXTI_GetITStatus(KEY1_INT_EXTI_LINE) != RESET)
{
// LED1 Take the opposite
LED1_TOGGLE;
// Clears the interrupt flag bit
EXTI_ClearITPendingBit(KEY1_INT_EXTI_LINE);
}
}
void EXTI15_10_IRQHandler(void)//PC13 Interrupt function
{
// Make sure that... Is generated EXTI Line interrupt
if(EXTI_GetITStatus(KEY2_INT_EXTI_LINE) != RESET)
{
// LED2 Take the opposite
LED2_TOGGLE;
// Clears the interrupt flag bit
EXTI_ClearITPendingBit(KEY2_INT_EXTI_LINE);
}
}
边栏推荐
- Shell logic case
- Epoll read / write mode in LT and et modes
- PRACH --- originator
- 嵌入式系统没有特别明确的定义
- Patent inquiry website
- Leetcode daily question (1856. maximum subarray min product)
- An executable binary file contains more than machine instructions
- Introduction to chromium embedded framework (CEF)
- Electronic product design
- Fundamentals of Electronic Technology (III)__ Chapter 1 resistance of parallel circuit
猜你喜欢
![[CSDN] C1 training problem analysis_ Part II_ Web Foundation](/img/91/72cdea3eb3f61315595330d2c9016d.png)
[CSDN] C1 training problem analysis_ Part II_ Web Foundation

端午节快乐!—— canvas写的粽子~~~~~

UCI and data multiplexing are transmitted on Pusch (Part VI) -- LDPC coding

Leetcode daily question (931. minimum falling path sum)
![[male nanny style] teach you to open the first wechat applet](/img/a1/a571609ee846adf75506a88a629906.png)
[male nanny style] teach you to open the first wechat applet

STM32 serial communication principle

MYSQL数据库底层基础专栏

Intelligent home design and development

Electronic product design

How does the nr-prach receiver detect the relationship between prembleid and Ta
随机推荐
Successful graduation [2] - student health management system function development...
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 5 --blinker_ MIOT_ MULTI_ Outside (lighting technology app + Xiaoai classmate control socket multiple jacks)
Simple use of MySQL (addition, deletion, modification and query)
Electronic product design
I didn't think so much when I was in the field of single chip microcomputer. I just wanted to earn money to support myself first
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
Project cost management__ Cost management technology__ Article 8 performance review
GPIO port details, Hal library operation keys
JMX、MBean、MXBean、MBeanServer 入门
UCI and data multiplexing are transmitted on Pusch - determine the bit number of harqack, csi1 and csi2 (Part II)
Embedded systems are inherently flawed. Compared with the Internet, there are so many holes that it is simply difficult to walk away from
Learn the contents of 5g toolbox supporting NR through the NR resources provided by MATLAB
Error output redirection
Leetcode daily question (985. sum of even numbers after queries)
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 3 --blinker_ MIOT_ Light (lighting technology app control + Xiaoai classmate control)
Flink CDC practice (including practical steps and screenshots)
SCM career development: those who can continue to do it have become great people. If they can't endure it, they will resign or change their careers
Runtime. getRuntime(). GC () and runtime getRuntime(). The difference between runfinalization()
There is no specific definition of embedded system
Nodemcu-esp8266 development board to build Arduino ide development environment