I'm trying to get PWM working with timer 3, I've followed the reference manual and believe i have everything correct but i get nothing on the output.
My code is below, I must be missing something
rcc_periph_clock_enable(RCC_GPIOB);
gpio_mode_setup(GPIOB, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,
GPIO0 | GPIO4 | GPIO5);
gpio_set_output_options(GPIOB, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,
GPIO0 | GPIO4 | GPIO5);
gpio_set_af(GPIOB, GPIO_AF2, GPIO0 | GPIO4 | GPIO5);
rcc_periph_clock_enable(RCC_TIM3);
timer_set_mode(TIM3, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
timer_set_prescaler(TIM3, 50000000 / 125000 - 1);
timer_enable_preload(TIM3);
timer_enable_oc_preload(TIM3, TIM_OC1);
timer_set_period(TIM3, 0xffff);
timer_enable_oc_output(TIM3, TIM_OC1);
timer_set_oc_mode(TIM3, TIM_OC1, TIM_OCM_PWM2);
// timer_set_oc_mode(TIM3, TIM_OC2, TIM_OCM_PWM2);
// timer_set_oc_mode(TIM3, TIM_OC3, TIM_OCM_PWM2);
timer_set_oc_value(TIM3, TIM_OC1, 0x7fff);
timer_enable_update_event(TIM3);
timer_generate_event(TIM3, TIM_EGR_UG);
timer_enable_counter(TIM3);