//按键PD6 按下产生中断,让PD15点亮,并打印。
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
USART_Configuration();//USART2 串口 更改晶振频率 由 25M HZ 变为 8M HZ
USART_NVIC_Config(); //在 system_stm32f4xx.c 中 #define 
LL_M 8 在 stm32f4xx.h 中 #define HSE_VALUE ((uint32_t)8000000)
/*开启GPIOD的外设时钟*/
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); //使能或者失能AHB外设时钟 , 此处是让D口外设时钟使
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//注意要打开SYSCFG时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; /*选择要控制的GPIOD引脚*/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; /*设置引脚模式为通用推挽输出*/
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; /*设置引脚速率为50MHz */
GPIO_Init(GPIOD, &GPIO_InitStructure); /*调用库函数,初始化GPIO*/
GPIO_ResetBits(GPIOD, GPIO_Pin_15);
/* GPIOD 
eriph clock enable */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
//GPIO_EXTILineConfig(GPIO_PortSourceGPIOD, GPIO_PinSource3);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOD, EXTI_PinSource6);
EXTI_InitStructure.EXTI_Line = EXTI_Line6;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable the USARTx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
while(1){};
大侠们帮我看看。我这个EXTI中断配置有错误不
我的程序肿么进不了中断处理函数中呢
?
以下是我的中断处理函数。
void EXTI9_5_IRQnHandler(void){
printf("
567
");
if(EXTI_GetITStatus(EXTI_Line6) != RESET) {
GPIO_Config(GPIOD,GPIO_Pin_15,GPIO_Mode_OUT,GPIO_OType_PP,GPIO_PuPd_NOPULL);
Delay(0x3FFFFF);
LedOnOff(GPIOD,GPIO_Pin_15,1);
Delay(0x3FFFFF);
EXTI_ClearITPendingBit(EXTI_Line13);
}
}
一周热门 更多>