void EXTI9_5_IRQHandler(void)
{
if((EXTI_GetITStatus(EXTI_Line7))!= RESET||(EXTI_GetITStatus(EXTI_Line8))!= RESET||(EXTI_GetITStatus(EXTI_Line9))!= RESET)
{t=key_date();
if(t==8)
{
speaker();
if(sensor_change < 5)
{
sensor_change ++;
}
else
{
sensor_change = 1;
}
}
if(t==3)
{
speaker();
if((sensor_change>=1)&&(sensor_change<=5))
{
index_bit = (unsigned int)(sensor_index);
index1 = index_bit/10000;
index2 = (index_bit%10000)/1000;
index3 = (index_bit%1000)/100;
index4 = (index_bit%100)/10;
index5 = index_bit%10;
switch(sensor_change)
{
case 1:
if(index1==9) index1 = 0;
else
index1++;
break;
case 2:
if(index2==9) index2 = 0;
else
index2++;
break;
case 3:
if(index3==9) index3 = 0;
else
index3++;
break;
case 4:
if(index4==9) index4 = 0;
else
index4++;
break;
case 5:
if(index5==9) index5 = 0;
else
index5++;
break;
}
sensor_index = index1*10000+index2*1000+index3*100+index4*10+index5;
}
}
EXTI_ClearITPendingBit(EXTI_Line7|EXTI_Line8|EXTI_Line9);
}
}
篇幅有限,只粘贴了主要部分,程序的意思是一个3*3的按键中断,t是判断哪个键被按下,t等于8时,那个键的意思是修改sensor_index这个参数,每按一次,就是修改该参数的第n位,对应的sensor_change加1;t等于3时,是向上加1键。我现在遇到的问题是:sensor_change初值为0,若是通过t=8的按键改变其值在1-5之间,则按t=3的键则进不去自己的中断,若是人为赋初值为1-5之间,就能进入该中断。本人刚接触不久,虚心求教 |