本帖最后由 abcdotaabc 于 2020-11-12 10:55 编辑
目前有个驱动步进电机的项目 用到了定时1通道4 比较输出模式产生脉冲 但是目前有概率性出现多一个尖脉冲情况
if (TIM_GetITStatus(TIM1, TIM_IT_CC4) != RESET)
{
// 清除定时器中断
TIM_ClearITPendingBit(TIM1, TIM_IT_CC4);
tim_count = TIM_GetCounter(TIM1);
tmp = tim_count+ 968;
TIM_SetCompare4(TIM1, tmp );
StepMotorPlus ++ ;
if(StepMotorPlus > 10)
{
TIM_CCxCmd(TIM1, TIM_Channel_4, TIM_CCx_Disable);
TIM_ClearITPendingBit(TIM1, TIM_IT_CC4);
GPIO_ResetBits(GPIOE, GPIO_Pin_14);
TIM_ITConfig(TIM1, TIM_IT_CC4, DISABLE );
MotionStatus_M1 = 0; // 电机为停止状态
}
}
|