当前位置:网站首页>Detailed explanation of exit interrupt
Detailed explanation of exit interrupt
2022-07-29 05:29:00 【Ryan fitter】
EXIT Interrupt details :
EXIT Structure :
typedef struct
{
uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled. This parameter can be any combination of @ref EXTI_Lines */
EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines. This parameter can be a value of @ref EXTIMode_TypeDef */
EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines. This parameter can be a value of @ref EXTIMode_TypeDef */
FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines. This parameter can be set either to ENABLE or DISABLE */
}EXTI_InitTypeDef;
1.EXTI_Line: To interrupt / Event line selection , All in all 20 A break line is ( stm32f10x_exit.h ) You can view in the header file .(EXIT0—EXIT19)
2.EXIT_Mode: Interrupt mode selection , The optional mode is generate interrupt / Produce an event
3.EXIT_Trigger : Edge triggered events , Optional rising edge trigger , Falling edge trigger , Or both rising and falling edges trigger
4.EXIT_LineCmd : Control whether to enable EXIT Line
NVIC Structure :
stay (misc.h) Header file
typedef struct
{
uint8_t NVIC_IRQChannel; /*!< Specifies the IRQ channel to be enabled or disabled. This parameter can be a value of @ref IRQn_Type (For the complete STM32 Devices IRQ Channels list, please refer to stm32f10x.h file) */
uint8_t NVIC_IRQChannelPreemptionPriority; /*!< Specifies the pre-emption priority for the IRQ channel specified in NVIC_IRQChannel. This parameter can be a value between 0 and 15 as described in the table @ref NVIC_Priority_Table */
uint8_t NVIC_IRQChannelSubPriority; /*!< Specifies the subpriority level for the IRQ channel specified in NVIC_IRQChannel. This parameter can be a value between 0 and 15 as described in the table @ref NVIC_Priority_Table */
FunctionalState NVIC_IRQChannelCmd; /*!< Specifies whether the IRQ channel defined in NVIC_IRQChannel will be enabled or disabled. This parameter can be set either to ENABLE or DISABLE */
} NVIC_InitTypeDef;
1.NVIC_IRQChannel : Set interrupt channel
2.NVIC_IRQChannelPreemptionnPriority : Set preemption priority
3.NVIC_IRQChannelSubPriority : Set sub priority
4.NVIC_IRQChannelCmd: Control whether to enable Interrupt controller
The following table gives the basis NVIC_PriorityGroupConfig Function to configure the allowed priority and secondary priority values
| NVIC_PriorityGroup | NVIC_IRQChannelPreemptionPriority | NVIC_IRQChannelSubPriority | Description |
|---|---|---|---|
| NVIC_PriorityGroup_0 | 0 | 0-15 | 0 bits for pre-emption priority 4 bits for subpriority |
| NVIC_PriorityGroup_1 | 0-1 | 0-7 | 1 bits for pre-emption priority 3 bits for subpriority |
| NVIC_PriorityGroup_2 | 0-3 | 0-3 | 2 bits for pre-emption priority 2 bits for subpriority |
| NVIC_PriorityGroup_3 | 0-7 | 0-1 | 3 bits for pre-emption priority 1 bits for subpriority |
| NVIC_PriorityGroup_4 | 0-15 | 0 | 4 bits for pre-emption priority 0 bits for subpriority |
As can be seen from the table, first compare the preemption priority NVIC_IRQChannelPreemptionPriority The smaller the number, the better , Then compare the sub priorities NVIC_IRQChannelSubPriority It's the same thing .
How to configure interrupt function :
1. Initializes the used to interrupt GPIO
2. initialization EXIT ( Edge detection circuit ----> Rising edge / Falling edge trigger interrupt )
3. To configure NVIC( Interrupt priority )
4. Write service functions ( It can be found in the startup file startup_stm32f10x_hd.s Find )
Interrupt procedure and IO To configure :
#include "exit.h"
void Exit_config_Iinit(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);// Interrupt bit multiplexing, so turn on the multiplexing clock
// To configure GPIO
GPIO_InitTypeDef Gpio_Init;
Gpio_Init.GPIO_Mode = GPIO_Mode_IPD;
Gpio_Init.GPIO_Pin = GPIO_Pin_1;
Gpio_Init.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_Init(GPIOA,&Gpio_Init);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA,GPIO_PinSource1);//GPIO Configuration of interrupt line
// To configure EXTI External interrupt
EXTI_InitTypeDef Exit_Init;
Exit_Init.EXTI_Line = EXTI_Line1;
Exit_Init.EXTI_Mode = EXTI_Mode_Interrupt;
Exit_Init.EXTI_Trigger = EXTI_Trigger_Falling;
Exit_Init.EXTI_LineCmd = ENABLE;
EXTI_Init(&Exit_Init);
// Configure the interrupt controller
NVIC_InitTypeDef Nvic_Init;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
Nvic_Init.NVIC_IRQChannel = EXTI1_IRQn;
Nvic_Init.NVIC_IRQChannelPreemptionPriority = 1;
Nvic_Init.NVIC_IRQChannelSubPriority = 1;
Nvic_Init.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&Nvic_Init);
}
Interrupt service function configuration :
void EXTI1_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line1) != RESET)// Determine whether an interruption has occurred
{
GPIO_ResetBits(GPIOC,GPIO_Pin_13);
delay(1000);
GPIO_SetBits(GPIOC,GPIO_Pin_13);
}
EXTI_ClearFlag(EXTI_Line1);// Clears the interrupt flag bit
}
The rising edge of the above interrupt is triggered and lit LED Pause 1s Put out after .
边栏推荐
- 直播预告|如何通过“智能边缘安全”提升企业免疫力?
- 文件结尾
- 365 day challenge leetcode 1000 questions - day 039 full binary tree inserter + find peak II + snapshot array
- Custom QML control: imagebutton
- 365 day challenge leetcode 1000 questions - day 037 elements and the maximum side length of squares less than or equal to the threshold + the number of subsequences that meet the conditions
- How to get command parameters in Visual Basic.Net
- 千人规模互联网公司研发效能成功之路
- Alibaba cloud and Dingjie software released the cloud digital factory solution to realize the localized deployment of cloud MES system
- 200 多家 ISV 入驻!阿里云计算巢发布一周年
- 重定向和文件
猜你喜欢
随机推荐
来!看排名一年上升16位的ClickHouse,如何在京东落地实践
直播预告|如何通过“智能边缘安全”提升企业免疫力?
R & D efficiency | analysis of kubernetes' core technology and Devops' landing experience
京东云联合Forrester咨询发布混合云报告 云原生成为驱动产业发展新引擎
水一篇图的拓扑排序
Helm chart for Kubernetes
Cryengine3 debugging shader method
C语言 N皇后问题
·来一篇编程之路的自我介绍吧·
QML custom tabbar
Side effects and sequence points
指针
如视技术副总裁杨永林:当传统产业遇到“数字空间”
【C语言系列】— 字符串+部分转义字符详解+注释小技巧
分配内存:malloc()和free()
365 day challenge leetcode 1000 questions - day 042 array sequence number conversion + relative ranking discretization processing
Why is Google's internal tools not suitable for you?
副作用和序列点
AiTalk创始人梁宇淇:镜像连接虚拟与现实的纽带
Storage category









