本帖最后由 panyibin133 于 2014-11-22 22:32 编辑
下面是我根据原子的例子修改的中断代码,但是数据捕获为何数据是相同的?
void TIM2_IRQHandler(void)
{
if((TIM2CH2_CAPTURE_STA&0X80)==0)//还未成功捕获
{
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
if(TIM2CH2_CAPTURE_STA&0X40)
{
if((TIM2CH2_CAPTURE_STA&0X3F)==0X3F)
{
TIM2CH2_CAPTURE_STA|=0X80;
TIM2CH2_CAPTURE_VAL=0XFFFF;
}else TIM2CH2_CAPTURE_STA++;
}
if(TIM2CH3_CAPTURE_STA&0X40)
{
if((TIM2CH3_CAPTURE_STA&0X3F)==0X3F)
{
TIM2CH3_CAPTURE_STA|=0X80;
TIM2CH3_CAPTURE_VAL=0XFFFF;
}else TIM2CH3_CAPTURE_STA++;
}
}
if (TIM_GetITStatus(TIM2, TIM_IT_CC2) != RESET)
{
TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
if(TIM2CH2_CAPTURE_STA&0X40)
{
TIM2CH2_CAPTURE_STA|=0X80;
TIM2CH2_CAPTURE_VAL=TIM_GetCapture2(TIM2);
TIM_OC2PolarityConfig(TIM2,TIM_ICPolarity_Rising);
}
else
{
TIM2CH2_CAPTURE_STA=0; //清空
TIM2CH2_CAPTURE_VAL=0;
TIM_SetCounter(TIM2,0);
TIM2CH2_CAPTURE_STA|=0X40;
TIM_OC2PolarityConfig(TIM2,TIM_ICPolarity_Falling);
}
}
if (TIM_GetITStatus(TIM2, TIM_IT_CC3) != RESET)
{
TIM_ClearITPendingBit(TIM2,TIM_IT_CC3);
if(TIM2CH3_CAPTURE_STA&0X40)
{
TIM2CH3_CAPTURE_STA|=0X80;
TIM2CH3_CAPTURE_VAL=TIM_GetCapture3(TIM2);
TIM_OC3PolarityConfig(TIM2,TIM_ICPolarity_Rising);
}
else
{
TIM2CH3_CAPTURE_STA=0; //清空
TIM2CH3_CAPTURE_VAL=0;
TIM_SetCounter(TIM2,0);
TIM2CH3_CAPTURE_STA|=0X40;
TIM_OC3PolarityConfig(TIM2,TIM_ICPolarity_Falling);
}
}
}
}
+4465
-4465
-1638
+1638
-1635
。。。。中间还有数据正表示高电平负表示低电平,但是貌似不对啊都一样,空调遥控器的红外数据低电平的完全不对。。。
-513
+513
+512
-512
我需要捕获拷贝的波形
|