Skip to content

Instantly share code, notes, and snippets.

@synic
Created September 11, 2014 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save synic/ee674cb47dbab603e149 to your computer and use it in GitHub Desktop.
Save synic/ee674cb47dbab603e149 to your computer and use it in GitHub Desktop.
void setup_timer(void) {
rcc_periph_clock_enable(RCC_TIM3);
timer_reset(TIM3);
timer_set_mode(TIM3, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
timer_set_prescaler(TIM3, 0);
timer_set_clock_division(TIM3, 0);
timer_set_period(TIM3, PERIOD);
timer_set_oc_mode(TIM3, TIM_OC1, TIM_OCM_PWM1);
timer_set_oc_polarity_high(TIM3, TIM_OC1);
/* timer_set_dma_on_compare_event(TIM3);*/
timer_set_master_mode(TIM3, TIM_CCMR1_OC1M_PWM1);
timer_enable_oc_output(TIM3, TIM_OC1);
timer_enable_counter(TIM3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment