使用TIM1的反相输出功能,具体你可以看官方例程,大概代码如下://TIM1做PWM输出 void Tim1_Config(void) { TimerPeriod = (SystemCoreClock / 20000 ) - 1; ccr1 = TimerPeriod / 2; //占空比1/2 = 50% ccr2 = TimerPeriod / 3; //占空比1/3 = 33% ccr3 = TimerPeriod / 4; //占空比1/4 = 25% RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE); //时基初始化 TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1; //死区控制用。 TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Up; //计数器方向 TIM_TimeBaseInitStructure.TIM_Prescaler = 0; //Timer clock = sysclock /(TIM_Prescaler+1) = 168M TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0; TIM_TimeBaseInitStructure.TIM_Period = TimerPeriod - 1; TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure); 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_OCNPolarity = TIM_OCPolarity_High; TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set; TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Reset; TIM_OC1Init(TIM1,&TIM_OCInitStructure); TIM_Cmd(TIM1,ENABLE); TIM_CtrlPWMOutputs(TIM1,ENABLE); }例如使用OC1/OC1N两个通道输出反向信号如下,是否你要的效果? http://images.cnitblog.com/blog/79656/201306/02205939-6554aa9b793648eaa488822decfbf906.jpg http://images.cnitblog.com/blog/79656/201306/02205920-5fd79236b31440a7b3f8866608182bae.jpg http://images.cnitblog.com/blog/79656/201306/02205904-5b8abb9bf12b4f4f99be58965abeafa9.jpg
所在话题
参与活动
-
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16