我根据官方资料上的说明去配置这个定时器,发现在外部触发上升沿到来时,定时器并不会复位。但是 如果设置CR1_URS位,可以发现的确是产生了更新事件。这是怎么回事?
void TIM_Configuration( void )
{
TIM_ICInitTypeDef TIM_ICInitStructure;
//TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
TIM_SelectInputTrigger( TIM1, TIM_TIxExternalCLK1Source_TI1 );
TIM_SelectSlaveMode( TIM1, TIM_SlaveMode_Reset );
//TIM_TimeBaseInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
//TIM_TimeBaseInitStructure.TIM_CounterMode = TIM_CounterMode_Down;
//TIM_TimeBaseInitStructure.TIM_Period = 40;
//TIM_TimeBaseInitStructure.TIM_Prescaler = 0;
//TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0;
//TIM_TimeBaseInit( TIM1, &TIM_TimeBaseInitStructure );
TIM_CounterModeConfig( TIM1, TIM_CounterMode_Down );
//TIM_SetCounter( TIM1, 100 );
TIM_SetAutoreload( TIM1, 100 ); //当计数值为240时,计数溢出时间为 ( 1 / 24 ) * 240 = 10 us
TIM_ARRPreloadConfig( TIM1, DISABLE ); //禁止重装载
TIM_UpdateRequestConfig( TIM1, TIM_UpdateSource_Global );
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICFilter = 0; //不使用滤波器
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInit( TIM1, &TIM_ICInitStructure );
TIM_ITConfig( TIM1, TIM_IT_Update, ENABLE );
//TIM_ITConfig( TIM1, TIM_IT_Break, ENABLE );
TIM_ITConfig( TIM1, TIM_IT_Trigger, ENABLE );
} |