初中生
最后登录1970-1-1
在线时间 小时
注册时间2019-5-2
|
检查了好几遍都找不到为什么硬件没反应,PE3是按键,,,PA6是led灯,,求大佬帮我看看
static void NVIC_config(void )
{
NVIC_InitTypeDef NVIC_InitStruct;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
NVIC_InitStruct.NVIC_IRQChannel = EXTI3_IRQn ; //使能按键外部中断3通道
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0; //抢占优先级,
NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0; //响应优先级
NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE; //使能外部中断通道
NVIC_Init(&NVIC_InitStruct);
}
void _key_EXTI_config(void )
{
GPIO_InitTypeDef GPIO_InitStruct;
EXTI_InitTypeDef EXTI_InitStruct;
NVIC_config( );
RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOE, ENABLE); //开按键时钟
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; //100M
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOE,&GPIO_InitStruct);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); //中断线必须选择SYFCFG 系统时钟
SYSCFG_EXTILineConfig( EXTI_PortSourceGPIOE, EXTI_PinSource3); //GPIOE3与中断线连接
EXTI_InitStruct.EXTI_Line = EXTI_Line3 ; //中断线的标号,对于我们的外部中断,取值范围为EXTI_Line0~EXTI_Line15
EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt; //中断模式,可选值为中断EXTI_Mode_Interrupt和事件EXTI_Mode_Event。
EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Falling; //触发方式,可以是下降沿触发EXTI_Trigger_Falling,上升沿触发EXTI_Trigger_Rising
EXTI_InitStruct.EXTI_LineCmd = ENABLE; //配置中断分组(NVIC),并使能中断。
EXTI_Init(&EXTI_InitStruct); //将配置送入地址
}
void EXTI3_IRQHandler (void)
{
if(EXTI_GetITStatus(EXTI_Line3)!= RESET)
{
GPIO_ResetBits (LED_GPIO_PORT, LED_GPIO_PIN);
EXTI_ClearITPendingBit(EXTI_Line3);
}
}
|
|