2014-11-28 10:24 AM
Hello Guys,
I´m developing an application with STM32L and I would like to use TIM2 Input capture with TIM_ICPOLARITY_BOTHEDGE.When the interrupt occurs...Is there a way of knowing which Polarity has been detected?Maybe it can be able getting the digital value of this channel. If it is high Rising edge has occured. Isn´t it?Is there some better solution?2014-11-28 11:43 AM
Is there some better solution?
Use channel 1 & 2 to catch opposite edges, with channel 2 using TI1 (Timer Input 1)2014-11-28 12:01 PM
I only have one pin to do it
2014-11-28 12:16 PM
I only have one pin to do it
And so?2014-11-28 12:45 PM
I dont understand your answer sorry :(
2014-11-28 01:02 PM
Perhaps a diagram from the
might help... One pin, Two channels, Capturing opposite edges of the same Input. Each edge time stamps against the Time Base, Each generates a uniquely identifiable IRQ.2014-11-28 01:10 PM
Once again the correct answer. Thank you so much clive
2014-11-28 01:40 PM
Is this configuration correct??GPIO_InitStruct.Pin = GPIO_PIN_2;GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;GPIO_InitStruct.Pull = GPIO_PULLUP;GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;GPIO_InitStruct.Alternate = GPIO_AF2_TIM2;
¿How can I remap my PA2 pint to Alternate function CH4?
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);voidHAL_TIMInit(void){ // Enable TIM2 Clock __TIM2_CLK_ENABLE(); // Timer configuration TimHandle.Instance = TIM2; TimHandle.Init.Period = T2_FULL_SCALE; TimHandle.Init.Prescaler = T2_PSC; TimHandle.Init.ClockDivision = 0; TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP; HAL_TIM_IC_Init(&TimHandle); // Configure the Input Capture of channel 3 (PA2) sICConfig.ICPolarity = TIM_ICPOLARITY_FALLING; sICConfig.ICSelection = TIM_ICSELECTION_DIRECTTI; sICConfig.ICPrescaler = TIM_ICPSC_DIV1; sICConfig.ICFilter = 0; //0x03; // Input filter for 8 clock Cycles HAL_TIM_IC_ConfigChannel(&TimHandle, &sICConfig, TIM_CHANNEL_3); // Set the TIM2 global Interrupt HAL_NVIC_SetPriority(TIM2_IRQn, 0, 1); // Enable the TIM2 global Interrupt HAL_NVIC_EnableIRQ(TIM2_IRQn); // Start the Input Capture in interrupt mode HAL_TIM_IC_Start_IT(&TimHandle, TIM_CHANNEL_3); HAL_TIM_IC_Start_IT(&TimHandle, TIM_CHANNEL_4);}¿How can I configure CH4 with rising polarity?