我在用tim2的CH1和CH3做输入捕获的时候,两个通道会相互影响是怎么回事儿
这是中断服务程序,
#pragma vector = TIM2_CAPCOM_TIF_vector
__interrupt void TIM2_CAPCOM_TIF(void)
{
static unsigned int Ir[70];
static unsigned int Fg[24];
//i = (unsigned int)(8<<TIM2_CCR3H);
//i |= (unsigned int)(TIM2_CCR3L);
if(TIM2_SR1_CC1IF) //红外
{
if( TIM2_CCER1_CC1P) //下降沿产生的中断
{
Ir[i] = ( TIM2_CCR1H << 8 );
Ir[i] |= TIM2_CCR1L;
TIM2_CCER1_CC1P = 0; //改为上升沿捕获
i++;
}
else //上升沿产生的中断
{
Ir[i] = ( TIM2_CCR1H << 8 );
Ir[i] |= TIM2_CCR1L;
TIM2_CCER1_CC1P = 1; //改为下降沿捕获
i++;
}
if(i == 70){
i = 0;
}
}
if(TIM2_SR1_CC3IF) //FG
{
if(TIM2_CCER2_CC3P) //下降沿产生的中断
{
Fg[j] = ( TIM2_CCR3H << 8 );
Fg[j] |= TIM2_CCR3H;
j++;
//TIM2_CCER2 &=~ 0x02; //改为上升沿捕获
TIM2_CCER2_CC3P = 0;
}
else //上升沿产生的中断
{
Fg[j] = (TIM2_CCR3H << 8);
Fg[j] |= TIM2_CCR3L;
j++;
//TIM2_CCER2 |= 0x02; //改为下降沿捕获
TIM2_CCER2_CC3P = 1;
}
if(j==24)
{
j = 0;
}
}
TIM2_CNTRH = TIM2_CNTRL = 0;
}//*/ |