cancel
Showing results for 
Search instead for 
Did you mean: 

Input capture

Fabio Romeo
Associate II
Posted on July 07, 2017 at 17:44

Input capture Interrupt ignored.

Hi all. I have an STM32F429II. I am trying simply to use the input capture functionality for an external signal that pulses with 200 ms period.

The issue is that can't see the interrupt raising.

That's my code to init the IC :

void TIM_Config(void)

{

/* GPIOH clock enable */

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_Init(GPIOH, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOH, GPIO_PinSource11, GPIO_AF_TIM5); // Connect TIM pins to AF2

NVIC_InitTypeDef NVIC_InitStructure;

NVIC_InitStructure.NVIC_IRQChannel = TIM5_IRQn ;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;// era 0

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; // era 1

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;// Enable the TIM5 global Interrupt

NVIC_Init(&NVIC_InitStructure);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);

TIM_ICInitTypeDef TIM_InputCaptureInitStructure;

TIM_InputCaptureInitStructure.TIM_Channel = TIM_Channel_1;

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

/* Enable the CC1 Interrupt Request */

TIM_ITConfig(TIM5, TIM_IT_CC1, ENABLE);

/* TIM enable counter */

TIM_Cmd(TIM5, ENABLE);

}

And this is the Interrupt routine :

void TIM5_IRQHandler(void)

{ if (TIM_GetITStatus(TIM5, TIM_IT_CC1) == SET)

{

TIM_ClearITPendingBit(TIM5, TIM_IT_CC1);

rpm4 = TIM_GetCapture1(TIM5);

static char xx[12];

sprintf( xx, ' %l', rpm4 );

GUI_DispStringAt(xx,100,150);

}

TIM_ClearITPendingBit(TIM5, TIM_IT_CC1);

}

I put some breakpoints inside the Interrupt routine but nothing happens...

My external signal is a 5V signal ( this micro is 5V tolerant... ) with negative pulses...

-------- -------- ---------

|_| |_|

Any clue ?

Thanks in advance

Fabio

Note: this post was migrated and contained many threaded conversations, some content may be missing.
10 REPLIES 10
Posted on July 13, 2017 at 20:19

By the way... TIM5 is not 16 bit it's 32 as TIM2 isn't it ?