我想使用PE5输出PWM,复用Timer8 ch0,根据例程修改定时器后,一直无法输出,代码如下,请大神指导!!!
//PE5复用Timer8 ch0
timer_oc_parameter_struct timer_ocintpara;
timer_parameter_struct timer_initpara;
rcu_periph_clock_enable(RCU_AF);
rcu_periph_clock_enable(RCU_GPIOE);
gpio_pin_remap_config(GPIO_TIMER8_REMAP,ENABLE);
/*Configure PE5(TIMER8_CH0) as alternate function*/
gpio_init(GPIOE, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_5);
rcu_periph_clock_enable(RCU_TIMER8);
timer_deinit(TIMER8);
/* TIMER8 configuration */
timer_initpara.prescaler = 108;
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
timer_initpara.counterdirection = TIMER_COUNTER_UP;
timer_initpara.period = 500;
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
timer_initpara.repetitioncounter = 0;
timer_init(TIMER8,&timer_initpara);
/* CH0 configuration in PWM mode */
timer_ocintpara.outputstate = TIMER_CCX_ENABLE;
timer_ocintpara.outputnstate = TIMER_CCXN_DISABLE;
timer_ocintpara.ocpolarity = TIMER_OC_POLARITY_HIGH;
timer_ocintpara.ocnpolarity = TIMER_OCN_POLARITY_HIGH;
timer_ocintpara.ocidlestate = TIMER_OC_IDLE_STATE_LOW;
timer_ocintpara.ocnidlestate = TIMER_OCN_IDLE_STATE_LOW;
timer_channel_output_config(TIMER8,TIMER_CH_0,&timer_ocintpara);
timer_channel_output_pulse_value_config(TIMER8,TIMER_CH_0,250);
timer_channel_output_mode_config(TIMER8,TIMER_CH_0,TIMER_OC_MODE_PWM0);
timer_channel_output_shadow_config(TIMER8,TIMER_CH_0,TIMER_OC_SHADOW_DISABLE);
timer_primary_output_config(TIMER8,ENABLE);
/* auto-reload preload enable */
timer_auto_reload_shadow_enable(TIMER8);
timer_enable(TIMER8); |