关于STM32外部中断的开关问题

2019-07-21 08:25发布

void NVICInit(void)
{
    NVIC_InitTypeDef NVIC_InitStructure; 
EXTI_InitTypeDef EXTI_InitStructure; 
GPIO_InitTypeDef GPIO_InitStructure;
#ifdef  VECT_TAB_RAM   
    NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); 
#else 
    NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);   
#endif
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE);// 使能AFIO
    /**********配置优先级组****************************/
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置中断优先级
/*允许EXTI4中断 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource0);
EXTI_ClearITPendingBit(EXTI_Line0);
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //上升沿触发
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_LineCmd = ENABLE; //中断线使能
EXTI_Init(&EXTI_InitStructure);       //初始化外部中断

NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);      
}
void TIM4_IRQHandler(void)
{
if (TIM_GetITStatus(TIM4, TIM_IT_Update) != RESET)  //检查TIM1更新中断发生与否
{
TIM_ClearITPendingBit(TIM4, TIM_IT_Update);   //清除TIMx更新中断标志
TIM_ITConfig(TIM4, TIM_IT_Update, DISABLE); //关定时器4中断
   EXTI_InitStructure.EXTI_LineCmd = DISABLE; //中断线使能
}
}

这是我外部中断函数的初始化部分,我是想在定时器4里面关闭外部中断,结果就是关不了,请高手指点一下

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。