STM32F4329II忽略输入捕获中断

时间:2017-07-13 19:08:53

标签: input capture

STM32F4329II尝试使用输入捕获时忽略输入捕获中断

static void TIM_Config(void)

{

       RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOH, ENABLE);

       GPIO_InitTypeDef GPIO_InitStructure;

       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_PuPd_NOPULL;

       GPIO_PinAFConfig(GPIOH, GPIO_PinSource11, GPIO_AF_TIM5);   

       GPIO_Init(GPIOH, &GPIO_InitStructure);

       /* TIM5 clock enable */

       RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);

       TIM_ICInitTypeDef  TIM_InputCaptureInitStructure;

       TIM_InputCaptureInitStructure.TIM_Channel = TIM_Channel_2;

       TIM_InputCaptureInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;

       TIM_InputCaptureInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;

       TIM_InputCaptureInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;

       TIM_InputCaptureInitStructure.TIM_ICFilter = 0x0;

       TIM_ICInit(TIM5, &TIM_InputCaptureInitStructure);

       TIM_ClearFlag(TIM5, TIM_FLAG_CC2 );

       NVIC_InitTypeDef NVIC_InitStructure;

       NVIC_InitStructure.NVIC_IRQChannel = TIM5_IRQn ;

       NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

       NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

       NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;          // 

       NVIC_Init(&NVIC_InitStructure);

       TIM_PWMIConfig(TIM2, &TIM_ICInitStructure);

         //Enable CC2 interrupt
       TIM_ITConfig(TIM5,TIM_IT_CC2,ENABLE);
      //EnableTIM5
       TIM_Cmd(TIM5,ENABLE);

}

以下IRQ

    extern "C" void TIM5_IRQHandler(void)
    {
     if (TIM_GetITStatus(TIM5, TIM_IT_CC2) == SET)
     {
         TIM_ClearITPendingBit(TIM5, TIM_IT_CC2);

         rpm4 = TIM_GetCapture2(TIM5);
         static char xx[12];
         sprintf( xx, " %l", rpm4 );
         GUI_DispStringAt(xx,100,150);
     }

     TIM_ClearITPendingBit(TIM5, TIM_IT_CC2 );
}

我在中断例程中放了一些断点但没有任何反应...... 我的外部信号是一个5V信号(这个微电压是5V耐受的......),带有负脉冲......

0 个答案:

没有答案