本人使用的是TIM1 产生PWM
TIM_OCInitStruct.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStruct.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OCInitStruct.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStruct.TIM_OCNIdleState = TIM_OCNIdleState_Reset;
TIM_OCInitStruct.TIM_Pulse = MX_CCR1;
TIM_OC1Init(MX_PWM_TIM,&TIM_OCInitStruct);
TIM_OCInitStruct.TIM_Pulse = MX_CCR2;
TIM_OC2Init(MX_PWM_TIM,&TIM_OCInitStruct);
TIM_OCInitStruct.TIM_Pulse = MX_CCR3;
TIM_OC3Init(MX_PWM_TIM,&TIM_OCInitStruct);
TIM_OCInitStruct.TIM_Pulse = MX_CCR4;
TIM_OC4Init(MX_PWM_TIM,&TIM_OCInitStruct);
如没有没有这句:TIM_OCInitStruct.TIM_OCNIdleState = TIM_OCNIdleState_Reset;
单片机只能单独输出PWM 就只有 OC1 ,其它通道都没有,加入这句后 就没的问题了。
感觉好奇怪。
我用的单片机是STM32F103VET
|