TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; TIM_OCInitStructure.TIM_Pulse = ccr1; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStructure.TIM_OCNP...
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Reset; 2)、TIM1_CH1和TIM1_CH1N输出同时配置为低电平,当刹车信号到来时,会执行有效刹车; TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset; TIM_OCInitStructure.TIM_OCNIdleSt...
TimOCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; =(CCRx/ARR)*100%或(TIM_Pulse/TIM_Period)*100% TimOCInitStructure.TIM_Pulse = dutyfactor * 7200 / 100; //TIM输出比较极性高 TimOCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; //使能输出状态 TimOCInitStructure.TIM_OutputState = TIM_Output...
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure); TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStructure.TIM_Pulse = 25; if(pwm_output == PWM_OUTPUT_A10) { pw...
TIM_OCInitStructure.TIM_Pulse = ccr1; TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;//输出同相,TIM_OCNPolarity_High时输出反相 TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; ...
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2; //PWM模式2 TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;//正向通道有效 PA8 TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;//反向通道也有效PB13 TIM_OCInitStructure.TIM_Pulse = 40; //占空时间 144 中有40的时间...
TIM1_OCInitStructure.TIM_Pulse = 0x505; //dummy value //脉宽(占空比).TIM1_OCInitStructure.TIM...
TIM_OCInitStructure.TIM_Pulse = 2000; //翻转周期:2000个脉冲 TIM_OCInitStructure.TIM_OutputState...
以上是输出比较结构体的配置,他最后决定了PWM的参数,PWM的频率即前面的定时器定时周期。而占空比是由TIM_Pulse确定的。其中占空比公式为: = CCR寄存器的值 / ARR寄存器的值 = TIM_OCInitStructure.TIM_Pulse / TIM_TimeBaseStructure.TIM_Prescaler-1 //TIM3->CCER &= 0xEEEF; ...
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;TIM_OCInitStructure.TIM_Pulse = CCR1...