AnsweredAssumed Answered

TIM17 PWM

Question asked by bit.udi on Jul 19, 2011
Latest reply on May 28, 2015 by Clive One
Hi,
I am trying to produce PWM signal by using TIM17 channel1 on PORTB-9,
but i can't get the PWM signal.
In debug mode i can see that TIM17 COUNTER register advanced and do overloop, but i just cant see the PWM signal on PORTB-9.
I configured RCC, GPIO and TIM (in this order as seen below).
Can any one give a hand?
THanks!

/************************************RCC***************************************************
  /* Setup the microcontroller system. Initialize the Embedded Flash Interface, 
     initialize the PLL and update the SystemFrequency variable. */
  SystemInit();
 
  /*Configures the AHB clock (HCLK).*/
  RCC_HCLKConfig(RCC_SYSCLK_Div2);
 
  /*Configures the Low Speed APB clock (PCLK1).*/
  RCC_PCLK1Config(RCC_HCLK_Div1);
 
  /* Enable DMA1 clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
  
  /* Enable ADC1-Periph, and ADC-GPIO (as defined in MW_hw.h) clocks */
  RCC_APB2PeriphClockCmd(   RCC_APB2Periph_TIM17     |
                                                RCC_APB2Periph_GPIOB ,  ENABLE );

/************************************GPIO***************************************************

GPIO_InitTypeDef GPIO_InitStructure;
 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_Init(MW_CONTROL_GPIO, &GPIO_InitStructure);  


/************************************TIM17**************************************************
/* Time base configuration */
  TIM_TimeBaseStructure.TIM_Period = 11999;                  TIM_TimeBaseStructure.TIM_Prescaler = 0;     TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

  TIM_TimeBaseInit(TIM17, &TIM_TimeBaseStructure);

  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse =11999*20/100; //20%
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;  

TIM_OC1PreloadConfig(TIM17, TIM_OCPreload_Enable);
   
  TIM_ARRPreloadConfig(TIM17, ENABLE);
  
  TIM_Cmd(TIM17, ENABLE);
  // Enable PWM signal.
  TIM_CCxCmd(TIM17, TIM_Channel_1, TIM_CCx_Enable);
 

 

Outcomes