First of all, what's your control output, pwm? If it's PWM you need to modify it in two places one is the structure TIM_TimeBaseInit(TIM2, & TIM_TimeBaseStructure); Find the timer number corresponding to GPIOA.2, you can look it up in the manual, it doesn't have to be TIM2 but just to give you an example another struct TIM_OCInit(TIM2, & TIM_OCInitStructure); You'd better find a routine with comments, there are many on the Internet, just search \"stm32 timer\