AnsweredAssumed Answered

TIM2_IRQHandler never executes??!!

Question asked by m.srinath on Nov 13, 2011
Latest reply on Nov 14, 2011 by wybranczyk.dominik
Hello everyone,


I have tried to use GPIO PortB, Pin 10 (which i believe can use AF TIM2_Channel 3) to capture PWM signals on my stm32f2.  I am using the standard peripheral lib. 


I am having issues with the TIM2_IRQHandler never being called/executed.  Below is the code fragment to setup the GPIO, NVIC and TIM for PWMIN  - 


     GPIO_InitTypeDef GPIO_InitStructure;
     NVIC_InitTypeDef NVIC_InitStructure;
     TIM_ICInitTypeDef  TIM_ICInitStructure;




     RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); 




     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);




     GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_10;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; // Unclear on this setting
     GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
     GPIO_Init(GPIOB, &GPIO_InitStructure);




     GPIO_PinAFConfig(GPIOB, GPIO_PinSource10  , GPIO_AF_TIM2);




     NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
     NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
     NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
     NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
     NVIC_Init(&NVIC_InitStructure);




     TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;
     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_PWMIConfig(TIM2, &TIM_ICInitStructure);
    
     TIM_SelectInputTrigger(TIM2, TIM_TS_TI2FP2);  




     /* Select the slave Mode: Reset Mode */
     TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Reset);
     TIM_SelectMasterSlaveMode(TIM2,TIM_MasterSlaveMode_Enable);




     /* TIM enable counter */
     TIM_Cmd(TIM2, ENABLE);




     /* Enable the CC2 Interrupt Request */
     TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE); 




The IRQ Handler is as below (note num_vists is a global variable and it never seems to increase ) - 


void TIM2_IRQHandler(void) {
 
  TIM_ClearFlag(PPM_TIM,TIM_FLAG_CC1);
  TIM_ClearFlag(PPM_TIM,TIM_FLAG_CC2);
  TIM_ClearFlag(PPM_TIM,TIM_FLAG_CC3);
  TIM_ClearFlag(PPM_TIM,TIM_FLAG_CC4);
  TIM_ClearITPendingBit(PPM_TIM, TIM_IT_CC2);
  TIM_ClearITPendingBit(PPM_TIM, TIM_IT_CC1);




  num_vists++;




}


Can anyone help me figure out what I have done wrong (i.e. why is the IRQ handler never visited).


Regards,
Srinath

Outcomes