PWM 设定程式如下
//...TCC 2013 03/25 PWM設定(馬達動作用(20k震盪)) 短手用
void TIM5_CH1_(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_TimeBaseStructure.TIM_Prescaler = 2;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_Period = 1200;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM5, &TIM_TimeBaseStructure);
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM2;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;
TIM_OCInitStructure.TIM_Pulse = 200;//(TIM_TimeBaseStructure.TIM_Period+1)/2; //duty cycle
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low ;
TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_High;
TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;
TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
TIM_OC1Init(TIM5, &TIM_OCInitStructure);
//TIM_Cmd(TIM5, ENABLE); // TIM1 counter enable
TIM_SetCompare1(TIM5,600);
}
程式1开始执行时PWM就1值在震盪,就算是TIM_CtrlPWMOutputs(TIM5, DISABLE);
也停不下来,要设定TIM_Cmd(TIM5, DISABLE); 才能停下
请问:TIM_CtrlPWMOutputs(TIM5, DISABLE);不是关闭PWM指令吗?
关闭PWM的指令到地是什麽?
请高手们指点 谢谢
|