定时器中断初始化存在问题

2019-07-20 03:26发布

void TimeInterrupt_InIt(u16 arr,u16 pas)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStruct;
NVIC_InitTypeDef NVIC_InitStruct;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);

TIM_TimeBaseInitStruct.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInitStruct.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInitStruct.TIM_Period=arr;
TIM_TimeBaseInitStruct.TIM_Prescaler=pas;
TIM_TimeBaseInit(TIM3,&TIM_TimeBaseInitStruct);

TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE);

NVIC_InitStruct.NVIC_IRQChannel=TIM3_IRQn;
NVIC_InitStruct.NVIC_IRQChannelCmd=ENABLE;
NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority=0x01;
NVIC_InitStruct.NVIC_IRQChannelSubPriority=0x03;
NVIC_Init(&NVIC_InitStruct);

TIM_Cmd(TIM3,ENABLE); //执行到这句就没法执行出来了
}


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。