求大神帮看看程序
void TIM2_Config()
{
TIM_InitStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_InitStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_InitStructure.TIM_Period=36000;
TIM_InitStructure.TIM_Prescaler=0;
TIM_InitStructure.TIM_RepetitionCounter=0;
TIM_TimeBaseInit(TIM2,&TIM_InitStructure);
TIM_OCInitStructure.TIM_OCMode=TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OCPolarity=TIM_OCPolarity_High;
TIM_OCInitStructure.TIM_Pulse=18000;
TIM_OCInitStructure.TIM_OutputState=TIM_OutputState_Enable;
TIM_OC4Init(TIM2,&TIM_OCInitStructure);
TIM_OC4PreloadConfig(TIM2, TIM_OCPreload_Enable);
TIM_ARRPreloadConfig(TIM2, ENABLE);
TIM_Cmd(TIM2,ENABLE);
}
用TIM2的CH4输出PWM 可是没反应。。。
此帖出自
小平头技术问答
其次,看看GPIO端口是否初始化了;
第三,看看时钟是否开启了,大概包括GPIO的时钟、定时器时钟、AFIO时钟;
最后,看看你设置的参数是否正确。
一周热门 更多>