STM32F107芯片,对TIM1的初始化如下:
/*TIM base Configuration*/
TIM_TimeBaseInitStructure.TIM_Prescaler = 0;
TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInitStructure.TIM_Period = 7199;
//72M /7200=10K
TIM_TimeBaseInitStructure.TIM_ClockDivision = 0;
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure);
/*pwm output configuartion*/
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = 3599;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM1, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM1, TIM_OCPreload_Enable);
如此配置之后,使用示波器测得PWM输出周期为60us(其实想要的是100us的),这么算TIM1的时钟是7200/60us=120M,怎么回事? |