STM32F030外部中断配置

1、说明

STM32F030芯片,PC13为外部中断触发,下降沿的配置;

注意开启SYSCFG时钟

void back_key_init(void)
{
	EXTI_InitTypeDef EXTI_InitStructure;		//EXTIx中断线配置
	NVIC_InitTypeDef NVIC_InitStructure;		//EXTIx中断向量配置

	pin_input_init(BACK_KEY);					//浮空输入,原理图已上拉
	
	//配置按键引脚为下降沿中断	
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG,ENABLE);	
	SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC,EXTI_PinSource13);	//将EXTI13指向PC13
		
	EXTI_InitStructure.EXTI_Line=EXTI_Line13;
	EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt;
	EXTI_InitStructure.EXTI_Trigger=EXTI_Trigger_Falling;
	EXTI_InitStructure.EXTI_LineCmd=ENABLE;
	EXTI_Init(&EXTI_InitStructure);
	
	NVIC_InitStructure.NVIC_IRQChannel=EXTI4_15_IRQn;
	NVIC_InitStructure.NVIC_IRQChannelPriority=0x01;
	NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
	NVIC_Init(&NVIC_InitStructure);

}

void EXTI4_15_IRQHandler(void){
	
	if(EXTI_GetITStatus(EXTI_Line13)!=RESET){	//判断是EXTI_Line13
		
	}
	EXTI_ClearFlag(EXTI_Line13);				//退出中断时清除标志位
}

你可能感兴趣的:(STM8/STM32,stm32)