外部中斷(External Interupt) 在MCU中是很常見而且很常用到的基本function,所以就不多做解釋。不過因為每顆MCU的配置都不太一樣所以在此記錄下來。

External Interrupt 配置

 void EXIT_GPIO_Config(void)
{
GPIO_InitTypeDef GPIO_Config;
EXTI_InitTypeDef EXTI_Config;
NVIC_InitTypeDef NVIC_Config; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); GPIO_Config.GPIO_Mode = GPIO_Mode_IN;
GPIO_Config.GPIO_OType = GPIO_OType_PP;
GPIO_Config.GPIO_Pin = GPIO_Pin_0;
GPIO_Config.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Config.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_Init(GPIOA, &GPIO_Config); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0); EXTI_Config.EXTI_Line = EXTI_Line0;
EXTI_Config.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_Config.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_Config.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_Config); NVIC_Config.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_Config.NVIC_IRQChannelSubPriority = 0x01;
NVIC_Config.NVIC_IRQChannelPreemptionPriority = 0x01;
NVIC_Config.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_Config); printf("External interrupt initial finished !!\n");
}

中斷向量內的程式碼

 void EXTI0_IRQHandler(void)
{
if(EXTI_GetFlagStatus(EXTI_Line0) != RESET)
{
printf("interrupt test\n");
EXTI_ClearITPendingBit(EXTI_Line0);
}
}

主程式

 /* Private variables ---------------------------------------------------------*/
__IO uint32_t status; int main(void)
{
LED_Config();
Delay_Init(); /* initialize delay function */
USART_Config();
EXIT_GPIO_Config();
printf("STM32F4 External Function test\n"); while()
{
status = GPIOA->IDR & GPIO_Pin_0;
if(status)
GPIOD->ODR |= GPIO_Pin_12;
else
GPIOD->ODR &= ~GPIO_Pin_12;
DelayMs();
}
}

(STM32F4) External Interrupt的更多相关文章

  1. STM32F4 External interrupts

    STM32F4 External interrupts Each STM32F4 device has 23 external interrupt or event sources. They are ...

  2. PIC32MZ tutorial -- External Interrupt

    In my older blog "PIC32MZ tutorial -- Key Debounce", I shows how to acheive key debounce w ...

  3. External Input Counter and External interrupt

    External Input Counter and External interrupt : count the input signal from the button. So what is t ...

  4. Software UART, Timer, PWM, External Interrupt

    How can you add extra hardware UARTs to a 32bit TMS470 ARM7-based microcontroller at zero cost? Solu ...

  5. STM32F4 External event -- WFE 待机模式

    The STM32F4xx are able to handle external or internal events in order to wake up the core (WFE). The ...

  6. STM8L --- External interrupt

    note 1:  Several interrupts can be pending at the same time. When an interrupt request is not servic ...

  7. 10.2 External interrupt/event controller (EXTI)

    EXTI控制器的主要特点如下: 每个中断/事件线上的独立触发器和掩码 每个中断行的专用状态位 生成最多20个软件事件/中断请求 脉冲宽度小于APB2时钟周期的外部信号检测. 每条中断线路的专用状态位生 ...

  8. stm32F4中断分析-HAL库

    详细可以参考: STM32使用HAL库操作外部中断——实战操作 https://www.cnblogs.com/wt88/p/9624103.html /** ******************** ...

  9. STM32F4, USB HS with ULPI and Suspend/Wakeup

    Hi guys,I am in need of your help, unfortunately STs documentation is lacking some information here. ...

随机推荐

  1. 19-EasyNetQ:用EasyNetQ.Hosepipe重新提交错误信息

    EasyNetQ.Hosepipe是EasyNetQ队列管理工具.用来取回队列中的消息并重新发布这些消息.还可以用它来检测错误队列,并重试发布消息. 用法 EasyNetQ.Hosepipe.exe ...

  2. Bootstrap 概览

    目录1.移动设备2.响应式图片3.Normalize4.Containers 1.移动设备在Bootstrap 3中,我们重写了整个框架,使其一开始就是对移动设备友好的.这次不是简单的增加一些可选的针 ...

  3. layer使用总结一配置

    导入layer.js文件即可,必须先导入jquery.js文件,因为layer是基于jquery 版本匹配,在此记录一下,layer使用1.8下载时是2.3的版本,对应的jquery使用1.8.3版本 ...

  4. win7安装linux双系统

    整体流程大概就是下载启动盘制作工具以及linux镜像,这些步骤网上很多,我就不再重复了 这里以centos举例说几个我踩到的坑吧 1.选择开始安装后提示 Warning: /dev/root does ...

  5. 1、 Shiro框架:认证,授权(验权 2. Shiro框架实现权限控制方式:

    1. Shiro框架:认证,授权(验权) a) 认证逻辑:applicationCode—>通过工具类获取subject对象,调用login方法参数令牌信息->安全管理器------> ...

  6. Ubuntu下配置Apache的Worker模式

    其实Apache本身的并发能力是足够强大的,但是Ubuntu默认安装的是Prefork模式下的Apache.所以导致很多人后面盲目的去 安装lighttpd或者nginx一类替代软件.但是这类软件有一 ...

  7. 32.GROUP BY

    合计函数 (比如 SUM) 常常需要添加 GROUP BY 语句. GROUP BY 语句 GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组. SQL GROUP BY 语法 ...

  8. zigbee之MAC地址发送

    TI cc2530在出厂时候每一个芯片都固化了一个唯一的8个字节的地址,MAC或者IEEE地址. 协调器模块的MAC地址为:0x00124B000716550F(注意自己的是多少!!) 终端的MAC地 ...

  9. IntelliJ IDEA——利用maven插件构建web工程

  10. Which Uri Encoding method should i use in C#/.net?

    June 19, 2015 This too is one of the boring "factual" posts. Sorry Lachlan. I never know w ...