cancel
Showing results for 
Search instead for 
Did you mean: 

Input capture STM32F429 Discovery

michelemancini2
Associate III
Posted on February 21, 2014 at 12:30

Hi,

I have a problem with F429 Discovery board. I use PB4 (is a free pin) for input capture This the configuration:

void TIM_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
/* TIM3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
/* GPIOB clock enable */
RCC_AHB1PeriphResetCmd (RCC_AHB1Periph_GPIOB, ENABLE);
/* TIM3 chennel1 configuration : PB.04 */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
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_UP ;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Connect TIM pin to AF4 */
GPIO_PinAFConfig(GPIOB, GPIO_PinSource4, GPIO_AF_TIM3);
/* Enable the TIM3 global Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_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_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV8;
TIM_ICInitStructure.TIM_ICFilter = 0x0;
TIM_ICInit(TIM3, &TIM_ICInitStructure);
/* TIM enable counter */
TIM_Cmd(TIM3, ENABLE);
/* Enable the CC1 Interrupt Request */
TIM_ITConfig(TIM3, TIM_IT_CC1, ENABLE);
}
__IO uint16_t IC2Value = 0;
void TIM3_IRQHandler(void)
{
/* Clear TIM3 Capture compare interrupt pending bit */
TIM_ClearITPendingBit(TIM3, TIM_IT_CC1);
/* Get the Input Capture value */
IC2Value = TIM_GetCapture1(TIM3);
}

When I toggle the PB4, never happen Why?
2 REPLIES 2
Posted on February 21, 2014 at 13:31

RCC_AHB1PeriphResetCmd (RCC_AHB1Periph_GPIOB, ENABLE);

NOT Reset, you want to enable the clock.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
michelemancini2
Associate III
Posted on February 21, 2014 at 13:51

I missed

,

thank you very much