(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. ...
随机推荐
- Lecture Sleep(前缀和)
Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells ai the ...
- 解决 Python 连不上pip库的问题(使用国内镜像地址)
经常在使用python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上 ...
- jar包上传到jcenter
H:\[BOOT]\gradle-5.0-bin\gradle-5.0\gradle.properties # in $HOME/.gradle/gradle.properties java6Home ...
- 值得一做》关于并查集的进化题目 BZOJ1015(BZOJ第一页计划)(normal-)
这道题和以前做过的一道经典的洪水冲桥问题很像,主要做法是逆向思维.(BZOJ第10道非SB题纪念) 先给出题目 Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者 ...
- GridSearchCV scoring 参考
http://scikit-learn.org/stable/modules/model_evaluation.html Scoring parameter: Model-evaluation too ...
- 997D Cycles in product
传送门 题目大意 https://www.luogu.org/problemnew/show/CF997D 分析 我们发现两棵树互不相关 于是我们可以分别求出两棵树的信息 我们点分,人啊按后设f[i] ...
- You-need-to-know-css
半透明边框 背景知识: background-clip <div class="main"> <input id="pb" type=&quo ...
- 6.Dump域内用户Hash姿势集合
本文转自先知社区,原文链接:https://xz.aliyun.com/t/2527#toc-10 原文地址:https://pentestlab.blog/2018/07/04/dumping-do ...
- POJ 1160 Post Office (四边形不等式优化DP)
题意: 给出m个村庄及其距离,给出n个邮局,要求怎么建n个邮局使代价最小. 析:一般的状态方程很容易写出,dp[i][j] = min{dp[i-1][k] + w[k+1][j]},表示前 j 个村 ...
- 第02章-装配Bean
1. Spring配置的可选方案 在XML中进行显式配置: 在Java中进行显式配置: 隐式的bean发现机制和自动装配. 2. 自动化装配bean Spring从两个角度来实现自动化装配: 组件扫描 ...