本帖最后由 M.gtd 于 2015-3-1 16:48 编辑
晶振频率 8MHz
mcu频率 72MHz
pwm初始化----------------------------------------
TIM_DeInit(TIM1);
TIM_TimeBaseStructInit(&TIM1_TimeBaseStructure);
/* Time Base configuration */
TIM1_TimeBaseStructure.TIM_Prescaler = 0x0; //internal clock with no dividing
TIM1_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_CenterAligned1;//
TIM1_TimeBaseStructure.TIM_Period = 4500; //频率设计为72M/(4500*2)=8k
TIM1_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV2; //for dead time clock
// Initial condition is REP=1 to set the UPDATE only on the underflow
TIM1_TimeBaseStructure.TIM_RepetitionCounter = REP_RATE; //REP_RATE=1;
TIM_TimeBaseInit(TIM1, &TIM1_TimeBaseStructure);
TIM_OCStructInit(&TIM1_OCInitStructure);
------------------------------------------------------------------------------
使用过程中发现pwm频率大于8K,在8.8K左右,百思不得其解,会不会是晶振不准?
|