本帖最后由 小小涛 于 2015-1-21 10:45 编辑 void Tim3_Init(u16 period_num) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE); TIM_DeInit(TIM3); TIM_TimeBaseStructure.TIM_Period=period_num; //prescaler is 1200,that is 72000000/72/500=2000Hz; TIM_TimeBaseStructure.TIM_Prescaler=72-1; //set clock division TIM_TimeBaseStructure.TIM_ClockDivision=TIM_CKD_DIV1; //or TIM_CKD_DIV2 or TIM_CKD_DIV4 //count up TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up; TIM_TimeBaseInit(TIM3,&TIM_TimeBaseStructure); TIM_ClearITPendingBit(TIM3,TIM_IT_Update); //TIM2 overflow interrupt enable TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); //clear the TIM2 overflow interrupt flag TIM_ClearFlag(TIM3,TIM_FLAG_Update); //enable TIM2 TIM_Cmd(TIM3,ENABLE); }为什么我一启动定时器,状态寄存器里的值是0x1f,无法清除!定时器有计数但却一直进不了中断!求指教啊!! |
帮顶,坛友请帮忙看看 |
解决了吗? |