void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
if(TIM3 == htim->Instance)
{
switch(capture_Cnt){
case 1://捕获到第一个上升沿
ExPulse_Input = 1;
HAL_GPIO_WritePin(LED2_GPIO,LED2_GPIO_PIN,GPIO_PIN_SET);
htim3.Instance->CNT = 0;
htim5.Instance->CNT = 0;
HAL_TIM_Base_Start(&htim4);//
HAL_TIM_Base_Start(&htim8);//
// HAL_TIM_IC_Stop_IT(&htim3,TIM_CHANNEL_1); //停止捕获
HAL_TIM_Base_Start_IT(&htim8);
capture_Cnt++;
MSpeed_capture_Buf[0] = HAL_TIM_ReadCapturedValue(&htim3,TIM_CHANNEL_1);
__HAL_TIM_SET_CAPTUREPOLARITY(&htim3, TIM_CHANNEL_1, TIM_INPUTCHANNELPOLARITY_FALLING);//开启下降沿捕获
break;
case 2://捕获到第二个上升沿,用来进行低速的测量,目前测试效果不好,可以不用管这一段
ExPulse_Input = 2;
MSpeed_capture_Buf[1] = HAL_TIM_ReadCapturedValue(&htim3,TIM_CHANNEL_1);
HAL_TIM_IC_Stop_IT(&htim3,TIM_CHANNEL_1); //停止捕获
// __HAL_TIM_DISABLE_IT(&htim3,TIM_IT_UPDATE);
capture_Cnt++;
MSpeed_capture_Buf[2] = TIM3_CNT;
break;
case 3://计数时间到时捕获到的最后一个上升沿 2
ExPulse_Input = 3;
// capture_Buf[1] = HAL_TIM_ReadCapturedValue(&htim16,TIM_CHANNEL_1);//闁兼儳鍢茶ぐ鍥亹閹惧啿顤呴柣銊ュ瀹曠喖鎳㈤敓????????????????????.
HAL_TIM_IC_Stop_IT(&htim3,TIM_CHANNEL_1); //闁稿绮嶉娑㈠箲閺囷拷?锟界?????????? 闁瑰瓨锟????: __HAL_TIM_DISABLE(&htim5);
HAL_TIM_Base_Stop(&htim4);//閿燂??????????????閸氼垶鐝0鎴炴闁界喖顣堕敓锟??????
HAL_TIM_Base_Stop(&htim8);//閿燂??????????????閸氼垵绶崗銉ㄥ墻閸愯尪顓搁弫鏉挎珤
HAL_TIM_Base_Stop(&htim1);
HAL_TIM_Base_Stop(&htim3);
HAL_TIM_Base_Stop(&htim5);
__HAL_TIM_DISABLE_IT(&htim3,TIM_IT_UPDATE);
HAL_GPIO_WritePin(LED2_GPIO,LED2_GPIO_PIN,GPIO_PIN_RESET);
capture_Cnt++;
capture_Buf[1] = htim4.Instance->CNT;//HAL_TIM_ReadCapturedValue(&htim3,TIM_CHANNEL_1);//闁兼儳鍢茶ぐ鍥亹閹惧啿顤呴柣銊ュ瀹曠喖鎳㈤敓????????????????????.
HIGHFRE_Buf[1] = htim8.Instance->CNT;//HAL_TIM_ReadCapturedValue(&htim4,TIM_CHANNEL_1);
if(ThighFre_CNT != 0)
{
HIGHFRE_Buf[3] = ((ThighFre_CNT) * 65535 + HIGHFRE_Buf[1]);//*2.5;
ThighFre_CNT = 0;
CAL_HIGHFRE_Buf[1] = HIGHFRE_Buf[3];
}
else
{
HIGHFRE_Buf[3] = HIGHFRE_Buf[1];// * 2.5;
CAL_HIGHFRE_Buf[1] = HIGHFRE_Buf[1];
}
if(TExPulse_CNT != 0)
{
capture_Buf[3] = ((TExPulse_CNT) * 65535 + capture_Buf[1]);//*2.5;
TExPulse_CNT = 0;
CAL_capture_Buf[1] = capture_Buf[3];
}
else
{
capture_Buf[3] = capture_Buf[1] ;//* 2.5;
CAL_capture_Buf[1] = capture_Buf[1];
}
break;
}
}
}
|