void TIM3_Configuration() { TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE); TIM_DeInit(TIM3); TIM_TimeBaseStructure.TIM_Period=2000; //ARR的值 TIM_TimeBaseStructure.TIM_Prescaler=36000; TIM_TimeBaseStructure.TIM_ClockDivision=0; //采样分频 TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up; //向上计数模式 TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure); TIM_ClearFlag(TIM3, TIM_FLAG_Update); TIM_ARRPreloadConfig(TIM3, DISABLE);//禁止ARR预装载缓冲器 TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); TIM_Cmd(TIM3, ENABLE); //开启时钟 } void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; #ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 [设置中断向量表的起始位置0x20000000]*/ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000[设置中断向量表的起始位置0x0x08000000] */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel=TIM3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority=1; NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; NVIC_Init(&NVIC_InitStructure); } void TIM3_IRQHandler(void) { if(TIM_GetFlagStatus(TIM3,TIM_IT_Update)!=RESET) { //TIM_ClearITPendingBit(TIM3,TIM_FLAG_Update); GPIO_ResetBits(GPIOB,GPIO_Pin_3); count++; if(count>100)count=0; } } |
回复:stm32 TIM3中断一直进不去,求大虾指点
RE:stm32 TIM3中断一直进不去,求大虾指点
你都把这句话屏蔽了,进入中断服务函数怎么出来呢