按键程序加在定时器中断服务函数中或者外部中断服务函数中为什么不起作用,而加在main函数里的while循环中就可以?
这是程序:
加载定时器中断服务函数中:
void
tiM3_IRQHandler(void) //TIM3中断
{
if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET) //检查指定的TIM中断发生与否:TIM 中断源
{
t = KEY_Scan(1); //得到键值
switch(t)
{
case WKUP_PRES: //特效设置
{
i++;
if(i == 6)
i = 0;
switch(i)
{
case 0:
OV7670_Special_Effects(0);
break;
case 1:
OV7670_Special_Effects(1);
break;
case 2:
OV7670_Special_Effects(2);
break;
case 3:
OV7670_Special_Effects(3);
break;
case 4:
OV7670_Special_Effects(4);
break;
case 5:
OV7670_Special_Effects(5);
break;
case 6:
OV7670_Special_Effects(6);
break;
default:
delay_ms(10);
}
}
break;
case KEY0_PRES: //对比度调节
{
k++;
if(k == 4)
k = 0;
switch(k)
{
case 0:
OV7670_Contrast(0);
break;
case 1:
OV7670_Contrast(1);
break;
case 2:
OV7670_Contrast(2);
break;
case 3:
OV7670_Contrast(3);
break;
case 4:
OV7670_Contrast(4);
break;
default:
delay_ms(10);
}
}
break;
default:
delay_ms(10);
}
}
TIM_ClearITPendingBit(TIM3, TIM_IT_Update ); //清除TIMx的中断待处理位:TIM 中断源
}
u8 i = 0;
u8 k = 0;
void EXTI0_IRQHandler(void)
{
delay_ms(10); //消抖
if(WK_UP==1) //特效设置
{
i++;
if(i == 6)
i = 0;
switch(i)
{
case 0:
OV7670_Special_Effects(0);
break;
case 1:
OV7670_Special_Effects(1);
break;
case 2:
OV7670_Special_Effects(2);
break;
case 3:
OV7670_Special_Effects(3);
break;
case 4:
OV7670_Special_Effects(4);
break;
case 5:
OV7670_Special_Effects(5);
break;
case 6:
OV7670_Special_Effects(6);
break;
default:
delay_ms(10);
}
}
EXTI_ClearITPendingBit(EXTI_Line0); //清除EXTI0线路挂起位
}
void EXTI9_5_IRQHandler(void)
{
delay_ms(10); //消抖
if(KEY0==0)
{
k++;
if(k == 4)
k = 0;
switch(k)
{
case 0:
OV7670_Contrast(0);
break;
case 1:
OV7670_Contrast(1);
break;
case 2:
OV7670_Contrast(2);
break;
case 3:
OV7670_Contrast(3);
break;
case 4:
OV7670_Contrast(4);
break;
default:
delay_ms(10);
}
}
EXTI_ClearITPendingBit(EXTI_Line5); //清除LINE5上的中断标志位
}
程序是ov7670摄像头图像采集的程序
一周热门 更多>