定时器中断的配置没有什么问题,可是中断服务函数进去后不知道为什么出不来,求大神帮忙分析一下,程序在下面:
int main(void)
{
/* Init Test Status LED */
TestStatusLedInit();
SysTick_Configuration();//Òª·ÅÔÚ¿¿Ç°µÄλÖÃ
/* Flash LED for test */
FlashLED ( 5 );
NVIC_Configuration();
GPIO_Configuration();
TIM2_Int_Init(499,7199);
while (1)
{
}
}
//TIM2µÄ¶¨Ê±Æ÷Öжϳõʼ»¯
//arr£º×Ô¶¯ÖØ×°Öµ
//psc£ºÊ±ÖÓÔ¤·ÖƵÊý
void TIM2_Int_Init(uint16_t arr,uint16_t psc)
{
TIMER_BaseInitPara TIM_TimeBaseStructure;
RCC_APB1PeriphClock_Enable(RCC_APB1PERIPH_TIMER2, ENABLE);
//³õʼ»¯TIM3
TIMER_DeInit(TIMER2);
TIM_TimeBaseStructure.TIMER_Period = arr; //ÉèÖÃÔÚÏÂÒ»¸ö¸üÐÂʼþ×°Èë»î¶¯µÄ×Ô¶¯ÖØ×°ÔؼĴæÆ÷ÖÜÆÚµÄÖµ
TIM_TimeBaseStructure.TIMER_Prescaler =psc; //ÉèÖÃÓÃÀ´×÷ΪTIMxʱÖÓƵÂʳýÊýµÄÔ¤·ÖƵֵ
TIM_TimeBaseStructure.TIMER_ClockDivision = TIMER_CDIV_DIV1; //ÉèÖÃʱÖÓ·Ö¸î:TDTS = Tck_tim
TIM_TimeBaseStructure.TIMER_CounterMode = TIMER_COUNTER_UP; //TIMÏòÉϼÆÊýģʽ
TIMER_BaseInit(TIMER2, &TIM_TimeBaseStructure); //¸ù¾ÝTIM_TimeBaseInitStructÖÐÖ¸¶¨µÄ²ÎÊý³õʼ»¯TIMxµÄʱ¼ä»ùÊýµ¥Î»
TIMER_CARLPreloadConfig(TIMER2,ENABLE);
TIMER_INTConfig(TIMER2,TIMER_INT_UPDATE,ENABLE);
TIMER_Enable(TIMER2, ENABLE);
}
void GPIO_Configuration(void)
{
GPIO_InitPara GPIO_InitStructure;
RCC_AHBPeriphClock_Enable(RCC_AHBPERIPH_GPIOC ,ENABLE);
/*Configure PA8(TIMER1 CH1) as alternate function*/
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_11;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_50MHZ;
GPIO_InitStructure.GPIO_OType = GPIO_OTYPE_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PUPD_NOPULL;
GPIO_Init(GPIOC,&GPIO_InitStructure);
}
/**
* @brief Configure the nested vectored interrupt controller.
* @param None
* @retval None
*/
void NVIC_Configuration(void)
{
NVIC_InitPara NVIC_InitStructure;
NVIC_PRIGroup_Enable(NVIC_PRIGROUP_1);
/* Enable the TIMER3 Interrupt */
NVIC_InitStructure.NVIC_IRQ = TIMER2_IRQn;
NVIC_InitStructure.NVIC_IRQPreemptPriority = 0;
NVIC_InitStructure.NVIC_IRQSubPriority = 1;
NVIC_InitStructure.NVIC_IRQEnable = ENABLE;
NVIC_Init(&NVIC_InitStructure);
} |