(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. ...
随机推荐
- 【原】Coursera—Andrew Ng机器学习—课程笔记 Lecture 6_Logistic Regression 逻辑回归
Lecture6 Logistic Regression 逻辑回归 6.1 分类问题 Classification6.2 假设表示 Hypothesis Representation6.3 决策边界 ...
- 【转】Spring事务介绍
1. 事务的特性:ACID 原子性(Atomicity):事务是一个原子操作,由一系列动作组成.事务的原子性确保动作要么全部完成,要么完全不起作用. 一致性(Consistency):一旦事务完成(不 ...
- 刷题向》DP》值得一做》关于对DP问题的充分考虑(normal)
在你辛苦调试一道DP题,遇到瓶颈的时候,你是否感到一股洪荒之力遏制住你的思想,使你给题库贡献了一倍的WA.RE.TLE量,却没有AC过一次? 在这时,你应该考虑的是砸电脑再次重新考虑整个题目,再应对自 ...
- Codeforces 1109C 线段树
题意及思路:https://www.cnblogs.com/TinyWong/p/10400682.html 代码: #include <bits/stdc++.h> #define ls ...
- 125. Valid Palindrome判断有效的有符号的回文串
[抄题]: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...
- java就业指南 zookeeper分布式系统 zookeeper实现分布式锁 有用
目前几乎很多大型网站及应用都是分布式部署的,分布式场景中的数据一致性问题一直是一个比较重要的话题.分布式的CAP理论告诉我们“任何一个 分布式系统都无法同时满足一致性(Consistency).可用性 ...
- Linux mii-tool命令
一.简介 mii-tool 是一个用来查看,管理介质的网络接口的状态的工具. 二.选项 usage: mii-tool [-VvRrwl] [-A media,... | -F media] [int ...
- Bean管理注解的例子
- sed陷阱
sed陷阱: sed -i 后不要紧跟字母, 否则会产生一个新的备份文件(在原文件后多出来一个字母) // 正确写法 /usr/bin/sed -i "/PREFIX=/d" ...
- requests基础
爬虫的基本原理:爬虫本质上是模拟人浏览信息的过程,只不过他通过计算机来达到快速抓取筛选信息的目的.所以我们想要写一个爬虫,最基本的就是要将我们需要抓取信息的网页原原本本的抓取下来.这个时候就要用到re ...