/*!
\brief configure TIMER primary output function
\param[in] timer_periph: TIMERx(x=0,14..16)
\param[in] newvalue: ENABLE or DISABLE
\param[out] none
\retval none
*/
void timer_primary_output_config(uint32_t timer_periph, ControlStatus newvalue)
{
if(ENABLE == newvalue){
TIMER_CCHP(timer_periph) |= (uint32_t)TIMER_CCHP_POEN;
}else{
TIMER_CCHP(timer_periph) &= (~(uint32_t)TIMER_CCHP_POEN);
}
}
是这个函数吧,加上了
昨天还是测试timer15,也是一样,没有输出PWM
timer_oc_parameter_struct timer_ocintpara;
timer_parameter_struct timer_initpara;
rcu_periph_clock_enable(RCU_TIMER15);
timer_deinit(TIMER15);
/* TIMER configuration */
timer_initpara.prescaler = 0; //9
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
timer_initpara.counterdirection = TIMER_COUNTER_UP;
timer_initpara.period = 4095; // 255
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
timer_initpara.repetitioncounter = 0;
timer_init(TIMER15,&timer_initpara);
/* configurate CH0 in PWM mode0 */
timer_ocintpara.ocpolarity = TIMER_OC_POLARITY_HIGH;
timer_ocintpara.outputstate = TIMER_CCX_ENABLE;
timer_channel_output_config(TIMER15,TIMER_CH_0,&timer_ocintpara);
timer_channel_output_pulse_value_config(TIMER15,TIMER_CH_0,2048); // 50% duty
timer_channel_output_mode_config(TIMER15,TIMER_CH_0,TIMER_OC_MODE_PWM0);
timer_channel_output_shadow_config(TIMER15,TIMER_CH_0,TIMER_OC_SHADOW_DISABLE);
/* auto-reload preload enable */
timer_auto_reload_shadow_enable(TIMER15);
// timer_automatic_output_enable(TIMER15);
timer_primary_output_config(TIMER15,ENABLE);
/* auto-reload preload enable */
timer_enable(TIMER15);
是不是APB2没有工作起来,但我一时半会还没有检查出APB2的问题
|