使用STM32f103c8t6单片机进行PWM实验时一直搞不懂TIM_ClockDivision是起什么作用?分的是哪个时钟的频率?还有就是TIM4明明是挂在APB1下的,APB1最高不是36M吗?为什么实测出来的工作频率是72M?从哪查看这些数据?
这是源代码:
void Init_tim4(uint16_t per,uint16_t psc)
{
TIM_TimeBaseInitTypeDef timebase_date;
TIM_OCInitTypeDef TIM4_OC_Init_date;
RCC_APB1PeriphClockCmd (RCC_APB1Periph_TIM4,ENABLE);
timebase_date .TIM_ClockDivision=1;
timebase_date .TIM_CounterMode=TIM_CounterMode_Up ;
timebase_date .TIM_Period =per ;//装置周期
timebase_date .TIM_Prescaler =psc ; //分频值
TIM_TimeBaseInit (TIM4 ,&timebase_date );
TIM4_OC_Init_date .TIM_OCMode =TIM_OCMode_PWM1 ;
TIM4_OC_Init_date .TIM_OCPolarity =TIM_OCPolarity_High ;
TIM4_OC_Init_date .TIM_Pulse =0;
TIM4_OC_Init_date .TIM_OutputState =TIM_OutputState_Enable;
TIM_OC3Init(TIM4,&TIM4_OC_Init_date );
TIM_OC3PreloadConfig (TIM4 ,TIM_OCPreload_Enable );
// TIM_ARRPreloadConfig (TIM4 ,ENABLE );
TIM_Cmd (TIM4,ENABLE );
|