STM32 EXTI的配置
时间:11-18
来源:互联网
点击:
interrupt on falling edge */
EXTI_InitStructure_EXTI_LINE7.EXTI_Line = EXTI_Line7; //配置 使能或失能的外部线路
EXTI_InitStructure_EXTI_LINE7.EXTI_Mode = EXTI_Mode_Interrupt; //配置 EXTI线路为中断请求 (或者是事件请求)
EXTI_InitStructure_EXTI_LINE7.EXTI_Trigger = EXTI_Trigger_Falling; //配置 使能线路的触发边沿 -- 下降沿触发中断
EXTI_InitStructure_EXTI_LINE7.EXTI_LineCmd = ENABLE; //配置 状态为使能
EXTI_Init(&EXTI_InitStructure_EXTI_LINE7); // 初始化外部中断线路7
/* Generate software interrupt: simulate a falling edge applied on EXTI line 7 */
EXTI_GenerateSWInterrupt(EXTI_Line7); //线路7产生一个软件中断
}
/*******************************************************************************
* Function Name : SysTick_Config SysTick设置
* Description : Configures SysTick
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SysTick_Config(void)
{
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Disable the SysTick Interrupt */
SysTick_ITConfig(DISABLE);
/* Configure HCLK clock as SysTick clock source */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
/* SysTick interrupt each 1000 Hz with HCLK equal to 72MHz */
SysTick_SetReload(9000);
/* Enable the SysTick Interrupt */
SysTick_ITConfig(ENABLE);
}
/*******************************************************************************
* Function Name : 精确延时函数
*******************************************************************************/
void Delay_Ms(u32 nTime)
{
/* Enable the SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Enable);
TimingDelay = nTime;
while(TimingDelay != 0);
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Clear SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Clear);
}
C语言:Codee#14818
/* Includes ------------------------------------------------------------------*/
#include "includes.h"
//#include "stm32f10x_it.h"
// ... ...
/*******************************************************************************
* Function Name : EXTI9_5_IRQHandler
* Description : This function handles External lines 9 to 5 interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
// LINE : 407
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line7) == SET) // 读取中断状态
{
LED1_HIGH ; LED2_HIGH ; LED3_HIGH ; LED4_HIGH ; // 灯全灭
EXTI_ClearITPendingBit(EXTI_Line7); // 清除标志位
}
}
EXTI_InitStructure_EXTI_LINE7.EXTI_Line = EXTI_Line7; //配置 使能或失能的外部线路
EXTI_InitStructure_EXTI_LINE7.EXTI_Mode = EXTI_Mode_Interrupt; //配置 EXTI线路为中断请求 (或者是事件请求)
EXTI_InitStructure_EXTI_LINE7.EXTI_Trigger = EXTI_Trigger_Falling; //配置 使能线路的触发边沿 -- 下降沿触发中断
EXTI_InitStructure_EXTI_LINE7.EXTI_LineCmd = ENABLE; //配置 状态为使能
EXTI_Init(&EXTI_InitStructure_EXTI_LINE7); // 初始化外部中断线路7
/* Generate software interrupt: simulate a falling edge applied on EXTI line 7 */
EXTI_GenerateSWInterrupt(EXTI_Line7); //线路7产生一个软件中断
}
/*******************************************************************************
* Function Name : SysTick_Config SysTick设置
* Description : Configures SysTick
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SysTick_Config(void)
{
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Disable the SysTick Interrupt */
SysTick_ITConfig(DISABLE);
/* Configure HCLK clock as SysTick clock source */
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
/* SysTick interrupt each 1000 Hz with HCLK equal to 72MHz */
SysTick_SetReload(9000);
/* Enable the SysTick Interrupt */
SysTick_ITConfig(ENABLE);
}
/*******************************************************************************
* Function Name : 精确延时函数
*******************************************************************************/
void Delay_Ms(u32 nTime)
{
/* Enable the SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Enable);
TimingDelay = nTime;
while(TimingDelay != 0);
/* Disable SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Disable);
/* Clear SysTick Counter */
SysTick_CounterCmd(SysTick_Counter_Clear);
}
(4)stm32f10x_it.c
C语言:Codee#14818
/* Includes ------------------------------------------------------------------*/
#include "includes.h"
//#include "stm32f10x_it.h"
// ... ...
/*******************************************************************************
* Function Name : EXTI9_5_IRQHandler
* Description : This function handles External lines 9 to 5 interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
// LINE : 407
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line7) == SET) // 读取中断状态
{
LED1_HIGH ; LED2_HIGH ; LED3_HIGH ; LED4_HIGH ; // 灯全灭
EXTI_ClearITPendingBit(EXTI_Line7); // 清除标志位
}
}
STM32EXT 相关文章:
- STM32 之 EXTI(12-03)
- stm32学习之六(12-03)
- STM32的exti中断调试遇到一奇怪问题总结(11-30)
- STM32 EXTI中断设置五步曲(11-26)
- STM32 EXTI外部中断(11-13)
- STM32学习笔记--EXTI(11-11)