哪位大神帮忙看下 怎么用定时器一产生两路pwm 没有波形 是什么问题呢

2019-07-19 20:37发布

TIM1_DeInit();
  TIM1_TimeBaseInit(16,TIM1_COUNTERMODE_UP,9999,0);
  TIM1_OC1Init(TIM1_OCMODE_PWM1, TIM1_OUTPUTSTATE_ENABLE,
               TIM1_OUTPUTNSTATE_DISABLE, 1000, TIM1_OCPOLARITY_HIGH,
               TIM1_OCNPOLARITY_LOW, TIM1_OCIDLESTATE_RESET, TIM1_OCNIDLESTATE_SET);
  TIM1_OC2Init(TIM1_OCMODE_PWM1, TIM1_OUTPUTSTATE_ENABLE,
               TIM1_OUTPUTNSTATE_DISABLE, 1000, TIM1_OCPOLARITY_HIGH,
               TIM1_OCNPOLARITY_LOW, TIM1_OCIDLESTATE_SET, TIM1_OCNIDLESTATE_SET);
  TIM1_CCxCmd(TIM1_CHANNEL_1, ENABLE);
  TIM1_CCxCmd(TIM1_CHANNEL_2, ENABLE);
  TIM1_OC1PreloadConfig(ENABLE);
  TIM1_OC2PreloadConfig(ENABLE);
  TIM1_CtrlPWMOutputs(ENABLE);
  TIM1_Cmd(ENABLE);

0条回答

一周热门 更多>