首页 > 代码库 > 步进电机转速控制

步进电机转速控制

void set_fre(unsigned int frequence)
{
int fre=0;
int fre_2=0;
fre=72000/frequence;
fre_2=fre/2;
 TIM_SetAutoreload( TIM4,fre-1);
 TIM_SetCompare1(TIM4,fre_2);//2?Dèòa??1!!

}


#if tim4
  TIM_TimeBaseInitStruct. TIM_Prescaler=0;     //?¤·??μoíperiodò??eéè??pwmμ??ü?ú
  TIM_TimeBaseInitStruct .TIM_CounterMode=TIM_CounterMode_Up;
  TIM_TimeBaseInitStruct .TIM_Period=9;//???ó??oí?¤·??μò??eéè??pwm?ü?ú
  TIM_TimeBaseInitStruct .TIM_ClockDivision=0;
  TIM_TimeBaseInit(TIM4, &TIM_TimeBaseInitStruct);