void TIM5_Int_Init(u16 arr,u16 psc)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE); //?±??????
TIM_TimeBaseStructure.TIM_Period = arr;
TIM_TimeBaseStructure.TIM_Prescaler =psc;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM5, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM5,TIM_IT_Update,ENABLE ); //
NVIC_InitStructure.NVIC_IRQChannel = TIM5_IRQn; //
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_Cmd(TIM5, ENABLE);
}
void TIM5_IRQHandler(void) //TIM3????
{
if (TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM5, TIM_IT_Update );
LED0=!LED0;
}
}
请问中断为啥进不去了,谢谢!!!!!!!!!!!!!!!!!!!!!!!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
定时器5跟定时器2,3,4是不是在一条总线上?
有没有可能你的单片机的定时器2,3,4是在APB1上,定时器5在APB2上?
1.在main中忘记调用 初始化设置per arr;
2.中断优先级和别的设置重复了
3.代码是从别的程序copy的,尽量手写代码不要复制特别是有注释的情况!
你们的代码都是手写的吗?
一周热门 更多>