您的位置 首页 IOT

如何用STM32装备一个EXTIx中断线的I/O口

如何用STM32配置一个EXTIx中断线的I/O口-//NVIC_CONFIG();

//2.配置EXTIx线的中断优先级

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

NVIC_InitStructure.NVIC_IRQChannel=EXTI3_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;

NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;

NVIC_Init(&NVIC_InitStructure);

GPIO_InitTypeDefGPIO_InitStructure;

EXTI_InitTypeDefEXTI_InitStructure;

NVIC_InitTypeDefNVIC_InitStructure;

//1.使能EXTIx线的时钟和第二功用AFIO时钟

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO|RCC_APB2Periph_GPIOA,ENABLE);

//NVIC_CONFIG();

//2.装备EXTIx线的中止优先级

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

NVIC_InitStructure.NVIC_IRQChannel=EXTI3_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;

NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;

NVIC_Init(&NVIC_InitStructure);

//3.装备EXTIx中止线的I/O口

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPD;

GPIO_Init(GPIOA,&GPIO_InitStructure);

GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource3);//4.选定要装备为EXTI的I/O口线

//5.EXTIx中止线的作业形式的装备

EXTI_InitStructure.EXTI_Line=EXTI_Line3;

EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling;

EXTI_InitStructure.EXTI_LineCmd=ENABLE;

EXTI_Init(&EXTI_InitStructure);

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/yingyong/iot/346800.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部