看手册中P202中写:如果使用了重复计数器功能,在向上计数达到设置的重复计数次数(TIMx_RCR)时,产生更新事件(UEV);否则每次计数器溢出时才产生更新事件。于是我想通过更新事件产生更新中断来验证,程序设置每次中断翻转IO口,代码如下:
void Timer1Config( void )
{
TIM_TimeBaseInitTypeDef oTIM1_TimeBaseStructure; //定义初始化TIM1结构体
oTIM1_TimeBaseStructure.TIM_Period = 7200;
oTIM1_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; //tDTS=1*tCK_INT
oTIM1_TimeBaseStructure.TIM_Prescaler = 0;
oTIM1_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //向上计数
oTIM1_TimeBaseStructure.TIM_RepetitionCounter = 6;
TIM_TimeBaseInit( TIM1,&oTIM1_TimeBaseStructure );
TIM_PrescalerConfig( TIM1,0,TIM_PSCReloadMode_Immediate );
TIM_ARRPreloadConfig( TIM1,DISABLE );
TIM_ClearFlag( TIM1,TIM_FLAG_Update );
TIM_ITConfig( TIM1,TIM_IT_Update,ENABLE ); //允许更新中断
TIM_Cmd( TIM1,ENABLE );
}
void TIM1_UP_IRQHandler( void )
{
if ( TIM_GetITStatus(TIM1,TIM_IT_Update) != RESET )
{
TIM_ClearITPendingBit( TIM1,TIM_IT_Update ); //必须手动清除标志位,否则一直中断
mWorkingLED_Toggle(); //for test
}
}
用keil MDK进行仿真实验,发现无论RCR设为多少(oTIM1_TimeBaseStructure.TIM_RepetitionCounter = 6这句),每次上溢都会进入中断,且RCR减一。并不像手册中说的只有当RCR=0时才产生更新,请问是我哪里配置出了问题吗? |