(STM32F4) External Interrupt
外部中斷(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的更多相关文章
- STM32F4 External interrupts
STM32F4 External interrupts Each STM32F4 device has 23 external interrupt or event sources. They are ...
- PIC32MZ tutorial -- External Interrupt
In my older blog "PIC32MZ tutorial -- Key Debounce", I shows how to acheive key debounce w ...
- External Input Counter and External interrupt
External Input Counter and External interrupt : count the input signal from the button. So what is t ...
- Software UART, Timer, PWM, External Interrupt
How can you add extra hardware UARTs to a 32bit TMS470 ARM7-based microcontroller at zero cost? Solu ...
- STM32F4 External event -- WFE 待机模式
The STM32F4xx are able to handle external or internal events in order to wake up the core (WFE). The ...
- STM8L --- External interrupt
note 1: Several interrupts can be pending at the same time. When an interrupt request is not servic ...
- 10.2 External interrupt/event controller (EXTI)
EXTI控制器的主要特点如下: 每个中断/事件线上的独立触发器和掩码 每个中断行的专用状态位 生成最多20个软件事件/中断请求 脉冲宽度小于APB2时钟周期的外部信号检测. 每条中断线路的专用状态位生 ...
- stm32F4中断分析-HAL库
详细可以参考: STM32使用HAL库操作外部中断——实战操作 https://www.cnblogs.com/wt88/p/9624103.html /** ******************** ...
- 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. ...
随机推荐
- Full Binary Tree(sdut 2882)
Problem Description: In computer science, a binary tree is a tree data structure in which each node ...
- 【290】Python 常用说明
1. 双击直接运行 python 代码暂停显示的方法:python学习笔记(3)--IDLE双击运行后暂停 需要添加如下代码: import os os.system("pause" ...
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 2_Linear regression with one variable 单变量线性回归
Lecture2 Linear regression with one variable 单变量线性回归 2.1 模型表示 Model Representation 2.1.1 线性回归 Li ...
- FeiQ项目
一.映射表 UDPMeditor.h中: typedef void (UDPMeditor::*pFunc)(char*,long); struct ProtocolMap { PackdefType ...
- Python和其他语言的区别 (简单精辟啊 手打)
首先是简单 读和写非常容易 免费 免费且开源 社区为专业人士和初学者提供知识和经验的分享交流平台 兼容性 与多平台兼容 面向对象 支持面向对象编程 php面向网络 函数库 python 社区创建了丰富 ...
- SpringMVC第二天
SpringMVC第二天 框架课程 1. 课程计划 1.高级参数绑定 a) 数组类型的参数绑定 b) List类型的绑定 2.@RequestMapping注解的使用 3.Controller方法 ...
- Browsersync 简介 and 使用
简介 省时的浏览器同步测试工具,Browsersync能让浏览器实时.快速响应您的文件更改(html.js.css.sass.less等)并自动刷新页面. 曾经我们每改一次的代码,都需要手动去刷新一次 ...
- Django框架 之 MTV模型、 基本命令、简单配置
浏览目录 MTV模型 Django框架前奏 Django基础必备三件套 Djaogo基本命令 MTV模型 Django的MTV分别代表: Model(模型):负责业务对象与数据库的对象(ORM) Te ...
- (一)ASP.NET中JavaScript的中英文(多语言)实现方案
PS: https://github.com/hzlzh/Front-End-Standards/wiki/HTML-CSS-JS-i18n 本文原始思路起源于此网址,请自行查看. 本文只是简单的一个 ...
- Adorner的收集
Adorners Overview https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/adorners-overview ' ...