TIM1 PWM问题求助 请高手一定看看 很急

2019-03-23 18:46发布

我用TIM1的六路控制电机      假如TIM1的  1通道   和1反通道    我失能1反通道   想让它为高电平 是在哪设置啊            现在是使能总是低电平,请懂的大侠一定帮忙看看 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
6条回答
199821756
2019-03-24 02:08
你帮我看看  我怎么找不到如何设置有效电平啊  我用的是固件库函数   刹车先不管  
TIM_TimeBaseStructure.TIM_Prescaler = 8; //4.5KHZ
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_Period = PWMOUTPUT_PERIOD;                //占空比为:CCRx/(TIM_Period+1)
  TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
  TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;        //重装次数为0
  TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);

  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 = PWMOUTPUT_DUTY;                 //设置CCR1值
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
  TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCPolarity_Low;
  TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Reset;
  TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;
  TIM_OC1Init(TIM1, &TIM_OCInitStructure);  //通道1配置

TIM_BDTRInitStructure.TIM_OSSRState = TIM_OSSRState_Enable;         //运行模式下“关闭状态”使能
  TIM_BDTRInitStructure.TIM_OSSIState = TIM_OSSIState_Enable;         //关闭模式下“关闭状态”使能
  TIM_BDTRInitStructure.TIM_LOCKLevel = TIM_LOCKLevel_OFF;                 //锁定关闭
  TIM_BDTRInitStructure.TIM_DeadTime = 80;                                                 //死区时间为13.8ns
  TIM_BDTRInitStructure.TIM_Break = TIM_Break_Disable;                         //刹车功能使能
  TIM_BDTRInitStructure.TIM_BreakPolarity = TIM_BreakPolarity_High;          //刹车输入高电平有效
  TIM_BDTRInitStructure.TIM_AutomaticOutput = TIM_AutomaticOutput_Enable;  //自动输出使能
  TIM_BDTRConfig(TIM1, &TIM_BDTRInitStructure);

一周热门 更多>