偶是菜鸟,在学习PWM时,相关设置如下:
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; //TIM1 脉冲调制模式2
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; //使能输出比较状态
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; //使能输出比较N状态
TIM_OCInitStructure.TIM_Pulse = CCR1_Val; //比较寄存器的脉冲值
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; //输出比较极性低
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High; //输出比较N极性低
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
TIM_OC1Init(TIM2, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Enable);
在定时器启用前,pwm口却输出高电平,但我需要启用定时器前pwm口为低电平
跪求大侠相助! |