stm32定时器的比较输出模式怎么确定脉冲的个数来控制步进电机?
用定时器的比较输出模式控制步进电机定时器配置:
TIM_TimeBaseStructure.TIM_Period = 999;//
TIM_TimeBaseStructure.TIM_Prescaler =71;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
/* PWM1 Mode configuration: Channel1 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Toggle; //输出比较模式
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = CCR1_Val; //
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM3, &TIM_OCInitStructure);
中断:
void TIM3_IRQHandler(void)
{
if(TIM_GetITStatus(TIM3,TIM_IT_CC1)!=RESET)
{
TIM_ClearITPendingBit(TIM3,TIM_IT_CC1);
capture1=TIM_GetCapture1(TIM3);
TIM_SetCompare1(TIM3,capture1+CCR1_Val);
}
}
改变CCR1_Val的值可以脉冲的频率和个数,但是CCR1_Val与脉冲的个数和频率的关系是怎样的,怎么算? 您好!不知道您调试出来了没有?我正在着手这块,也遇到了跟您一样的问题,怎么跟您联系?我的QQ345221603,谢谢了!!!{:smile:} 我也在做这一块
页:
[1]