AnsweredAssumed Answered

why cant I get PWM at TIM3 ?

Question asked by karakaya.mehmet on Jul 4, 2011
Latest reply on Jul 8, 2011 by 31696

void TIM3init(void) {
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
  /* Time base configuration */
  TIM_TimeBaseStructure.TIM_Period = 7200;
  TIM_TimeBaseStructure.TIM_Prescaler = 0;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;

  TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = 2000;
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

  TIM_OC3Init(TIM3, &TIM_OCInitStructure);
  TIM_OC4Init(TIM3, &TIM_OCInitStructure);

  TIM_CCPreloadControl(TIM3, DISABLE);

  TIM_Cmd(TIM3, ENABLE);
  TIM_CtrlPWMOutputs(TIM3, ENABLE);
}
void run_motor(void){
    TIM_SelectOCxM(TIM3, TIM_Channel_3, TIM_OCMode_PWM1);
    TIM_CCxCmd(TIM3, TIM_Channel_3, TIM_CCx_Enable);

    TIM_SelectOCxM(TIM3, TIM_Channel_4, TIM_ForcedAction_Active);
    TIM_CCxCmd(TIM3, TIM_Channel_4, TIM_CCx_Disable);
}

with above code I get logic "1" at TIM3_CH3
instead of PWM
can anybody help ?

Outcomes