准备用TIM1的Out Cmp功能来产生4个定时中断,下面的设置,却进不去中断服务程序?有什么问题吗?
/* Time Base configuration */ TIM1_TimeBaseStructure.TIM1_Prescaler = 0; TIM1_TimeBaseStructure.TIM1_CounterMode = TIM1_CounterMode_Up; TIM1_TimeBaseStructure.TIM1_Period = 65535; TIM1_TimeBaseStructure.TIM1_ClockDivision = 0; TIM1_TimeBaseStructure.TIM1_RepetitionCounter = 0;
TIM1_TimeBaseInit(&TIM1_TimeBaseStructure);
/* Channel 1, 2,3 and 4 Configuration in Timing mode */ TIM1_OCInitStructure.TIM1_OCMode = TIM1_OCMode_Timing; TIM1_OCInitStructure.TIM1_OutputState = TIM1_OutputState_Enable; TIM1_OCInitStructure.TIM1_OutputNState = TIM1_OutputNState_Enable; TIM1_OCInitStructure.TIM1_Pulse = CCR1_Val; TIM1_OCInitStructure.TIM1_OCPolarity = TIM1_OCPolarity_Low; TIM1_OCInitStructure.TIM1_OCNPolarity = TIM1_OCNPolarity_Low; TIM1_OCInitStructure.TIM1_OCIdleState = TIM1_OCIdleState_Reset; TIM1_OCInitStructure.TIM1_OCNIdleState = TIM1_OCIdleState_Reset; TIM1_OC1Init(&TIM1_OCInitStructure); TIM1_OC1PreloadConfig(TIM1_OCPreload_Disable); TIM1_ITConfig(TIM1_IT_CC1,ENABLE);
TIM1_OCInitStructure.TIM1_Pulse = CCR2_Val; TIM1_OC2Init(&TIM1_OCInitStructure); TIM1_OC2PreloadConfig(TIM1_OCPreload_Disable); TIM1_ITConfig(TIM1_IT_CC2,ENABLE);
TIM1_OCInitStructure.TIM1_Pulse = CCR3_Val; TIM1_OC3Init(&TIM1_OCInitStructure); TIM1_OC3PreloadConfig(TIM1_OCPreload_Disable); TIM1_ITConfig(TIM1_IT_CC3,ENABLE);
TIM1_OCInitStructure.TIM1_Pulse = CCR4_Val; TIM1_OC4Init(&TIM1_OCInitStructure); TIM1_OC4PreloadConfig(TIM1_OCPreload_Disable); TIM1_ITConfig(TIM1_IT_CC4,ENABLE);
/* TIM1 counter enable */ TIM1_Cmd(ENABLE); |