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);
步进电机转速控制
时间: 2024-10-10 07:58:48