在使用定时器1的CH0,toggle功能,在输出固定个数的脉冲时,脉冲个数正常,比较值也正常,但是最后一个波形异常,
if( timer_flag_get( TIMER1, TIMER_INT_FLAG_CH0 ) )
{
timer_interrupt_flag_clear( TIMER1, TIMER_INT_FLAG_CH0 ); //CH0IF = 0
// timer_flag_clear( TIMER1, TIMER_CH_0 );
//------------------------
tim_count = timer_counter_read( TIMER1 );
tmp = tim_count + Srd4.step_delay;
timer_channel_output_pulse_value_config( TIMER1, TIMER_CH_0, tmp );
//------------------
i++; //定时器中断次数计数值
if( i == 2 ) //说明已经输出一个完整脉冲
{
i = 0; //清零定时器中断次数计数值
#if 1
step_count++;
if( step_count >= 210 ) //超出210异常
{
step_count = 0;
timer_channel_output_state_config( TIMER1, TIMER_CH_0, TIMER_CCX_DISABLE ); //CH0EN = 0
timer_flag_clear( TIMER1, TIMER_CH_0 ); //CH0IF = 0
// timer_interrupt_flag_clear( TIMER1, TIMER_INT_FLAG_CH0 );
timer_interrupt_disable( TIMER1, TIMER_INT_CH0 ); //CH0IE = 0
}
#endif
}
不知大家有没有遇到过
|