这是我的外部中断配置
[mw_shl_code=c,true]void VALVE_EXTI_Init()
{
EXTI_InitTypeDef VALVE_EXTI_Initstructure;
NVIC_InitTypeDef VALVE_NVIC_Initstruccture;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource5);
VALVE_EXTI_Initstructure.EXTI_Line=EXTI_Line5;
VALVE_EXTI_Initstructure.EXTI_LineCmd=ENABLE;
VALVE_EXTI_Initstructure.EXTI_Mode=EXTI_Mode_Interrupt;
VALVE_EXTI_Initstructure.EXTI_Trigger=EXTI_Trigger_Falling;
EXTI_Init(&VALVE_EXTI_Initstructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE,GPIO_PinSource6);
VALVE_EXTI_Initstructure.EXTI_Line=EXTI_Line6;
VALVE_EXTI_Initstructure.EXTI_Mode=EXTI_Mode_Interrupt;
VALVE_EXTI_Initstructure.EXTI_Trigger=EXTI_Trigger_Falling;
VALVE_EXTI_Initstructure.EXTI_LineCmd=ENABLE;
EXTI_Init(&VALVE_EXTI_Initstructure);
VALVE_NVIC_Initstruccture.NVIC_IRQChannel=EXTI9_5_IRQn;
VALVE_NVIC_Initstruccture.NVIC_IRQChannelPreemptionPriority=0x02;
VALVE_NVIC_Initstruccture.NVIC_IRQChannelSubPriority=0x02;
VALVE_NVIC_Initstruccture.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&VALVE_NVIC_Initstruccture);
}
void EXTI9_5IRQHandler(void)
{
if(EXTI_GetFlagStatus(EXTI_Line5) !=RESET)
{
if(VALVE_IS_OPEN())
{
VALVE_STOP();
}
EXTI_ClearFlag(EXTI_Line5);
}
if(EXTI_GetFlagStatus(EXTI_Line6) !=RESET)
{
if(VALVE_IS_CLOSE())
{
VALVE_STOP();
}
EXTI_ClearFlag(EXTI_Line6);
}
}
int main(void)
{
valve_Init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
VALVE_EXTI_Init();
VALVE_OPEN();
}
[/mw_shl_code]
大概的意思是 触发中断后就电机停下来,但是 当触发外部按键时,,并没有触发中断
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>