程序如下: TIM_DeInit(TIM3); TIM3_TimeBaseStructure.TIM_Prescaler = 0x0; TIM3_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM3_TimeBaseStructure.TIM_Period = 0xFFFF; TIM3_TimeBaseStructure.TIM_ClockDivision = 0x0; TIM3_TimeBaseStructure.TIM_RepetitionCounter = 0x0; TIM_TimeBaseInit(TIM3,&TIM3_TimeBaseStructure); TIM3_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM3_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; TIM3_OCInitStructure.TIM_Pulse = CCR1_Val; TIM3_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low; TIM_OC1Init(TIM3,&TIM3_OCInitStructure); TIM_Cmd(TIM3,ENABLE); TIM_CtrlPWMOutputs(TIM3,ENABLE); 把TIM3换成TIM1就可以 蒙了我。。。。 |
回复:为什么我这样子设置PWM就是出不来呢?
回复:为什么我这样子设置PWM就是出不来呢?
是不是CPU没有time3,stm32的是103Fc6 R6,C4,R4是没有time3的。
呵呵。。。。解决了 因为最后的那个函数是在TIM1下用的 通用的TIM要加另外的两个函数