AnsweredAssumed Answered

STM32F TIM8 PWM

Question asked by brinker.michael on Sep 26, 2012
Latest reply on Sep 28, 2012 by brinker.michael
Hello!

I'm trying to get an STM32F407 with the LQFP176 Pinout to output in OC PWM1 mode.  My code is as follows:

  /* set up GPIO as timer output GPIOI 5, TIM 8 CH 1*/
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOI,ENABLE);
    GPIOInitS.GPIO_Pin = GPIO_PIN_174;
    GPIOInitS.GPIO_Mode = GPIO_Mode_AF;
    GPIOInitS.GPIO_Speed = GPIO_Speed_100MHz;
    GPIOInitS.GPIO_OType = GPIO_OType_PP;
    GPIOInitS.GPIO_PuPd = GPIO_PuPd_UP ;
    GPIO_Init(GPIOI, &GPIOInitS); 
    GPIO_PinAFConfig(GPIOI, GPIO_PinSource5,GPIO_AF_TIM8);
    
     /* set up timer hardware for PWM generation */
     RCC_APB2PeriphResetCmd(RCC_APB2Periph_TIM8, ENABLE);


    /* initialize timer to default values */
    TIM_TimeBaseStructInit(&TIMbaseS);
    TIMbaseS.TIM_Period = 0xffff;
    TIM_TimeBaseInit(TIM8, &TIMbaseS);


    /* configure output compare block */
    TIM_OCStructInit(&TIMOCinitS);
    TIMOCinitS.TIM_OCMode = TIM_OCMode_PWM1;
    TIMOCinitS.TIM_OutputState = TIM_OutputState_Enable;
    TIMOCinitS.TIM_Pulse = 3; 
    TIMOCinitS.TIM_OCPolarity = TIM_OCPolarity_High;
    TIM_OC1Init(TIM8, &TIMOCinitS);
    TIM_OC1PreloadConfig(TIM8,TIM_OCPreload_Enable);
    TIM_ARRPreloadConfig(TIM8, ENABLE);
    TIM_CtrlPWMOutputs(TIM8,ENABLE); /* TIM1/8 need extra command */
 
    TIM_Cmd(TIM8, ENABLE);

----------------------------

Unfortunately, I'm checking the output with an oscilloscope, and not getting anything out at all. What might I be doing wrong here?

Outcomes