请教用3.5库,初始化time1 时死机,帮帮忙啊!
TIM_DeInit(TIM1);//复位定时器
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 60000;//自动重装值 5ms@72MHz
TIM_TimeBaseStructure.TIM_Prescaler = 5;//予分频 时钟预分频+1
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;//倍频系数
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Down;//计数方向
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
TIM_ARRPreloadConfig(TIM1,ENABLE); //允许重装 TIM_Period
TIM_ITConfig(TIM1,TIM_IT_Update,ENABLE);//允许更新中断 关闭此句即可
TIM_Cmd(TIM1, ENABLE); //TIM2 运行
NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;//中断先优先级
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;//中断从优先级
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//开中断
NVIC_Init(&NVIC_InitStructure);//死在此
|