please look at the code below and tell me what wrong with the configuration. I used Stm32f4 discovery kit, and generated PWM via PC6, then connected it to PE11. However, no interupt occurred.
/*set the led to check if interrupt was access void TIM1_CC_IRQHandler(void) { if(TIM_GetITStatus(TIM1, TIM_IT_CC2) == SET) { GPIO_SetBits(GPIOD,GPIO_Pin_15); /* Clear TIM1 Capture compare interrupt pending bit */ TIM_ClearITPendingBit(TIM1, TIM_IT_CC2); } }
int main(void) { TIM3_Config(); PWM_TIM3_output(); TIM1_Config(); TIMICI_config(); Output_Configuration();//for blue led - GPIOD 15 while (1){} }
void TIMICI_config(void) { TIM_ICInitTypeDef TIM_ICInitStructure; TIM_ICInitStructure.TIM_Channel = TIM_Channel_2; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x0; TIM_ICInit(TIM1, &TIM_ICInitStructure); TIM_PWMIConfig(TIM1, &TIM_ICInitStructure); /* Select the TIM1 Input Trigger: TI2FP2 */ TIM_SelectInputTrigger(TIM1, TIM_TS_TI2FP2); /* TIM enable counter */ TIM_Cmd(TIM1, ENABLE); /* Enable the CC2 Interrupt Request */ TIM_ITConfig(TIM1, TIM_IT_CC2, ENABLE); }
void TIM1_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* TIM1 clock enable */ RCC_APB1PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE); /* GPIOE clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); /* TIM1 chennel2 configuration : PE.11 */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOE, &GPIO_InitStructure); /* Connect TIM pin to AF2 */ GPIO_PinAFConfig(GPIOE, GPIO_PinSource11, GPIO_AF_TIM1); /* Enable the TIM1 global Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = TIM1_CC_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); }