上升沿触发,进不去中断

2019-08-14 05:51发布

我想用PC7上升沿触发,配置成下拉输入。进不去中断求大神帮助!代码如下 [mw_shl_code=c,true]void Hallsensor_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; //init所有HALL 下拉输入 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE); //使能时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //设置成下拉输入 GPIO_Init(GPIOC, &GPIO_InitStructure); //初始化GPIOC } void EXTIX_Hall_Init(void) //霍尔传感器中断初始化中断 { EXTI_InitTypeDef EXTI_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); //GPIOC7 按键中断线以及中断初始化配置 发射按钮中断 GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource7); EXTI_InitStructure.EXTI_Line=EXTI_Line7; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); //根据EXTI_InitStruct中指定的参数初始化外设EXTI寄存器 NVIC_InitStructure.NVIC_IRQChannel =EXTI9_5_IRQn; //使能按键所在的外部中断通道 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01; //抢占优先级 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x03; //子优先级2 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能外部中断通道 NVIC_Init(&NVIC_InitStructure); } void EXTI9_5_RIQHandler(void) //HALL1中断服务程序 仅亮灯仿照KEY { Hall1_STATUS=0 ; if (EXTI_GetITStatus(EXTI_Line7) != RESET) { delay_ms(20); if(HALL1==1) { Hall1_STATUS = 1; } } EXTI_ClearITPendingBit(EXTI_Line7); }[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。