用限位开关做外部中断源,每次测试的时候都是前16次正常进中断,第17次,中断没反应,很奇怪。。。
[mw_shl_code=c,true]void EXTI9_5_IRQHandler(void)
{
int i;
u8 beep[1]={0x32};
u8 set[2]={0x00,0x01};
if(EXTI_GetITStatus(EXTI_Line9) != RESET){
if(1 == GPIO_ReadInputDataBit(GPIOD, GPIO_Pin_9))
{
if(moto_direction==2){
Moto_Off;
return_flag = 1;
warning_flag=1;
if(wirte_variable(0X0105,2,set)){}
if(one_push_flag){
testcount++;
if(testcount_set==0||testcount==testcount_set){
testcount_OK = 1;
TIM_Cmd(TIM6, DISABLE);
TIM_SetCounter(TIM6,0);
Init_flag_exti = 1;
}
else if(testcount_set>0&&testcount<testcount_set){
TIM_Cmd(TIM6, DISABLE);
TIM_SetCounter(TIM6,0);
back_flag = 1;
}
one_push_running = 0;
}
}
}
EXTI_ClearITPendingBit(EXTI_Line9);
}
}[/mw_shl_code]
[mw_shl_code=c,true]void EXTI1_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9| GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOD,&GPIO_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD,GPIO_PinSource8);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD,GPIO_PinSource9);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOD,GPIO_PinSource10);
EXTI_InitStructure.EXTI_Line = EXTI_Line8 | EXTI_Line9| EXTI_Line10;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
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);
}[/mw_shl_code]
一周热门 更多>