AnsweredAssumed Answered

Timer16 PWM Not Working

Question asked by Jo-Jo Smith on Oct 20, 2017
Latest reply on Oct 20, 2017 by Jo-Jo Smith

I am using an STM32F072B-DISCO. I am trying to get a PWM on pin A6 using timer 16. The timer seems to be counting as expected, but there is no output on A6.


Here is my code:


    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM16, ENABLE);


    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_6;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStruct);    
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_5);


    TIM_TimeBaseInitStruct.TIM_Period = 480;   //LED Intensity. Frequnecy (100kHz)
    TIM_TimeBaseInitStruct.TIM_Prescaler = 0;
    TIM_TimeBaseInit(TIM16, &TIM_TimeBaseInitStruct);
    TIM_OCInit.TIM_OCMode = TIM_OCMode_PWM1;
    TIM_OCInit.TIM_OutputState = TIM_OutputState_Enable;
    TIM_OCInit.TIM_OCPolarity = TIM_OCPolarity_High;
    TIM_OCInit.TIM_Pulse = 48;
    TIM_OC1Init(TIM16, &TIM_OCInit);
    TIM_Cmd(TIM16, ENABLE);


Can someone tell me why A6 does not have an output?