标签:utc 注意 cer star ++ putc stop 停止 def
main()
{
while(1)
{
if(capture_Cnt==0)
{
__HAL_TIM_SET_CAPTUREPOLARITY(&htim2,TIM_CHANNEL_2,TIM_INPUTCHANNELPOLARITY_RISING); //设置为上升沿捕获
HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_2);
capture_Cnt++;
}
}
}
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
if(TIM2 == htim->Instance)
{
if(capture_Cnt==1)
{
HAL_TIM_IC_Stop_IT(&htim2,TIM_CHANNEL_2); //停止捕获
capture_Cnt=0;
Number++;
}
}
}
注意修复以下bug
#define TIM_RESET_CAPTUREPOLARITY(__HANDLE__, __CHANNEL__) (((__CHANNEL__) == TIM_CHANNEL_1) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP))) : ((__CHANNEL__) == TIM_CHANNEL_2) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC2P | TIM_CCER_CC2NP)) : ((__CHANNEL__) == TIM_CHANNEL_3) ? ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC3P)) : ((__HANDLE__)->Instance->CCER &= ~(TIM_CCER_CC4P)))
第二行最后一个括号“)”删除
标签:utc 注意 cer star ++ putc stop 停止 def
原文地址:https://www.cnblogs.com/liusheldon/p/12924654.html