外部中斷(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. Python绘图matplotlib

    转自http://blog.csdn.net/ywjun0919/article/details/8692018 Python图表绘制:matplotlib绘图库入门 matplotlib 是pyth ...

  2. Linux下查看进程的命令输出的内容解释

    Linux下查看进程的命令输出的内容解释 ps (process status) ps -e 或者ps -A (-e和-A完全一样) PID           TTY         TIME   ...

  3. SqlServer数据导入到ORACLE

    ORACLE中执行 select * from SYSTEM."employ_epl"

  4. Zookeeper Api(java)入门与应用

    如何使用 Zookeeper 作为一个分布式的服务框架,主要用来解决分布式集群中应用系统的一致性问题,它能提供基于类似于文件系统的目录节点树方式的数据存储,但是 Zookeeper 并不是用来专门存储 ...

  5. idea maven项目依赖项有红色波浪线

    在maven面板选中所有报错的maven项目,右键选择移除(remove),之后重新添加.

  6. ZOJ3953 Intervals

    题意 有n个区间,要求删除一些区间使得不存在三个相交的区间.找出删除的最少区间. 分析 是个比较显然的贪心吧. 先按照区间的左起点进行排序,然后从左往右扫,当有三个区间相交的时候,删除那个右端点最远的 ...

  7. c# 二分查找法(2分钟算法)

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  8. zigbee--绑定

    1.绑定是zigbee一种基本通信方式:具体绑定通信又分为3种模式,在这里只拿一种源绑定来说明. 源绑定: 发送模块 :必须要知道接收模块(被绑定模块)的网络地址或者MAC地址 接收方的接收端点 接收 ...

  9. ArcGIS Desktop和Engine中对点要素图层Graduated Symbols渲染的实现 Rotation Symbol (转)

    摘要         ArcGIS中,对于要素图层的渲染,支持按照要素字段的值渲染要素的大小,其中Graduated Symbols可以对大小进行分级渲染.在个人开发系统的过程中,也可以用来美化数据显 ...

  10. 献上一款漂亮的手写PHP验证码

    献上一款漂亮的PHP验证码,可以根据个人需求作调整,代码如下(审美观不同,欢迎吐槽): <?php /** * Author: xiongwei * Email: 695704253@qq.co ...