Skip to main content
bfeixas
Associate II
March 4, 2010
Question

Example of PWM on TIM1 doesn't work

  • March 4, 2010
  • 3 replies
  • 715 views
Posted on March 04, 2010 at 10:02

Example of PWM on TIM1 doesn't work

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 13:42

    Looking at the code we have

     /* TIM1, GPIOA and GPIOB clock enable */

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 | RCC_APB2Periph_GPIOA |

                             RCC_APB2Periph_GPIOB, ENABLE);

    Personally, I think I'd make sure the AFIO clock is enabled.

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 | RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA |

                             RCC_APB2Periph_GPIOB, ENABLE);

    -Clive

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    dwooller
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 13:42

    I have had the same problem on the STM3210E-EVAL board using A8 PWM output from timer 1. Using the IAR compiler V5.4 I have found the following

    1). TIM_OCInitTypeDef , this needs to be defined outside of the initialisation function, if it is a local variable it does not work. (not sure why yet).

    2). Timer 1 has a master output enable, this must be turned on. It is different from timer 3 etc. (unable to find example using timer 1 in the ST examples). After setting up the modes etc enable using the following:-

      TIM_Cmd(TIM1, ENABLE);

      TIM_CtrlPWMOutputs(TIM1, ENABLE);

    Hope this helps,

    Dave

    bfeixas
    bfeixasAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 13:42

    I have changed it but it still doesn't work

    I need help