大学生
最后登录1970-1-1
在线时间 小时
注册时间2016-11-23
|
本帖最后由 龙王三太子 于 2017-4-21 14:46 编辑
有没有人帮忙看一下,为何按键中断触发了延时函数后,就不能事实的打断延时函数呢,反而每次都是等到延时函数完了以后,才可以进入下一次中断,我把延时函数放到野火的按键例程里面去试,反而是实时的进入中断,对比也没有看出啥问题,请教高人帮忙分析一下。
int main(void)
{
SystemInit();
Button_GPIO_Init();
while (1)
{
;
}
}
bool PassiveButton = true;
void Button_GPIO_Init(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC,GPIO_PinSource14);
EXTI_InitStructure.EXTI_Line =EXTI_Line14;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void EXTI15_10_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line14) != RESET) //è·±£êÇ·ñ2úéúáËEXTI LineÖD¶Ï
{
EXTI_ClearITPendingBit(EXTI_Line14); //Çå3yÖD¶Ï±ê־λ
delay_ms(1000);
delay_ms(1000);
delay_ms(1000);
delay_ms(1000);
}
}
void delay_ms(unsigned int time)
{
unsigned int i=0;
while(time--)
{
i=12000;
if(PassiveButton == true)
{
while(i--);
}
else
{
return;
}
}
}
|
|