配置的定时器0通道3 捕获PWM波无法捕获到,一直进中断,如下是我定时器的代码,不知道哪里的配置有问题,请求大神指导, timer_ic_parameter_struct timer_icinitpara;
timer_parameter_struct timer_initpara;
rcu_periph_clock_enable(RCU_TIMER0);
timer_deinit(TIMER0);
timer_initpara.prescaler = 83; //预分频
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
timer_initpara.counterdirection = TIMER_COUNTER_UP;
timer_initpara.period = 65535;
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
timer_initpara.repetitioncounter = 0;
timer_init(TIMER0, &timer_initpara);
/* TIMER0 configuration */
/* TIMER0 CH3 PWM input capture configuration */
timer_icinitpara.icpolarity = TIMER_IC_POLARITY_RISING;
timer_icinitpara.icselection = TIMER_IC_SELECTION_DIRECTTI;
timer_icinitpara.icprescaler = TIMER_IC_PSC_DIV1;
timer_icinitpara.icfilter = 0x0;
timer_input_pwm_capture_config(TIMER0, TIMER_CH_3, &timer_icinitpara);
/* slave mode selection: TIMER0 */
timer_input_trigger_source_select(TIMER0, TIMER_SMCFG_TRGSEL_CI0FE0);
timer_slave_mode_select(TIMER0, TIMER_SLAVE_MODE_RESTART);
/* select the master slave mode */
timer_master_slave_mode_config(TIMER0, TIMER_MASTER_SLAVE_MODE_ENABLE);
/* auto-reload preload enable */
timer_auto_reload_shadow_enable(TIMER0);
/* clear channel 0 interrupt bit */
timer_interrupt_flag_clear(TIMER0, TIMER_INT_CH3);
/* channel 0 interrupt enable */
timer_interrupt_enable(TIMER0, TIMER_INT_CH3);
/* TIMER0 counter enable */
timer_enable(TIMER0);
其中IO口和中断优先级已经确认配置无误,同时发现当前版本库这个函数timer_input_pwm_capture_config(TIMER0, TIMER_CH_3, &timer_icinitpara);的参数上没有TIMER_CH_3这一输入源,可能问题出现在这里,搞不懂。
|