void TIM5_IRQHandler(void)
{
if((TIM5CH1_CAPTURE_STA&0X80)==0)//????????????
{
if(TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET)//????
{
if(TIM5CH1_CAPTURE_STA&0X40)//?????????????????
{
if((TIM5CH1_CAPTURE_STA&0X3F)==0X3F)//?????????¤??
{
TIM5CH1_CAPTURE_STA|=0X80; //±ê????????????????
TIM5CH1_CAPTURE_VAL=0XFFFFFFFF;
}else TIM5CH1_CAPTURE_STA++;
}
}
if(TIM_GetITStatus(TIM5, TIM_IT_CC1) != RESET)//????1·??ú????????
{
if(TIM5CH1_CAPTURE_STA&0X40) //????????????????
{
TIM5CH1_CAPTURE_STA|=0X80; //±ê?????????????????????????í
TIM5CH1_CAPTURE_VAL=TIM_GetCapture1(TIM5);//?????±?°????????.
TIM_OC1PolarityConfig(TIM5,TIM_ICPolarity_Rising); //CC1P=0 ?è??????????????
}else //????????,????????????????
{
TIM5CH1_CAPTURE_STA=0; //????
TIM5CH1_CAPTURE_VAL=0;
TIM5CH1_CAPTURE_STA|=0X40; //±ê????????????????
TIM_Cmd(TIM5,DISABLE); //??±??¨?±?÷5
TIM_SetCounter(TIM5,0);//TIM5???????????±??????????
TIM_OC1PolarityConfig(TIM5,TIM_ICPolarity_Falling); //CC1P=1 ?è??????????????
TIM_Cmd(TIM5,ENABLE ); //?????¨?±?÷5
}
}
}
TIM_ClearITPendingBit(TIM5, TIM_IT_CC1|TIM_IT_Update); //????????±ê????
}
红 {MOD}标注的一行代码,这里关闭定时器TIM5,不知道在这里有什么用,我试着把他注释掉,做了几组实验,测试如下:
TIM_Cmd(TIM5,DISABLE):此时高电平时间为:2281163 us
TIM_Cmd(TIM5,ENABLE):此时高电平时间为:2395628 us
两次按键时间差不多,没看出DISABLE 和ENABLE 的区别,请问原子哥,这里代码加了一个TIM5不使能是为了什么考虑?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>