void TIM2_Init(void) { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE); TIM_DeInit(TIM2); /* Time base configuration */ TIM_TimeBaseStructure.TIM_Period = 0x7FFF; //自动重装载寄存器 TIM_TimeBaseStructure.TIM_Prescaler = 0x0; //预分频器 TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; // TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up|TIM_OPMode_Single; // TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_InternalClockConfig(TIM2); //内部时钟 TIM_ITConfig(TIM2,TIM_IT_Update,ENABLE);
TIM_Cmd(TIM2, ENABLE); } 没有中断成功!!! |