各位大神帮帮忙,定时器TIM4 进不了中断。还有哪儿配置错了,或者忘记配置的
void TIM4_Init(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM4, ENABLE);//36MHZ
TIM_TimeBaseStructure.TIM_Period = (10000-1);
TIM_TimeBaseStructure.TIM_Prescaler =(3599);
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode=TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE);
//TIM_SetCounter(TIM4,0);
TIM_Cmd(TIM4, ENABLE);
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x00);
NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIM_ClearITPendingBit(TIM4, TIM_IT_Update);
}
void TIM4_IRQHandler(void)
{
TIM_ClearITPendingBit(TIM4, TIM_IT_Update);
if(TIM_GetITStatus(TIM4, TIM_IT_Update) == SET)
{
led2_flash ^= LED2FLAH;
GPIOC->BSRR = led2_flash;
}
} |