Skip to main content
AKhor.1
Associate II
Aug 29, 2021 5:09 PM UTC
Question

Why time input capture does not work continiously?

Hello everyone.

I am working on a project that measures the duty cycle of the signal. I've initialized timer 1 as an input capture mode to measure the pulse width of a signal. Both input capture 1 and input capture 2 are used to signal the rising and the falling edge of the input signal respectively.

On the first try, the caputers were done fine, but it only captures once! for the next signal cycle, the capture registers wouldn'g change at all. So I can't calculate the signal width continously.The details of my project is as follow:

I've used STM32F103RET6, Timer 1, input caputers 1 and 2.

The program is written in STM32cubeIDE and CubeMx is used for configurations.

This topic has been closed for replies.

5 replies

waclawek.jan
Super User
Aug 29, 2021 9:00 PM UTC

Read out and check/post content of TIM registers.

JW

AKhor.1
AKhor.1Author
Associate II
Aug 30, 2021 3:59 AM UTC

The TIM register counts up correctly. No problem in counting. but no change in CCR1 and CCR2 register occurs.

0693W00000DlYc5QAF.jpg

waclawek.jan
Super User
Aug 30, 2021 7:04 AM UTC

Check all TIM registers, mainly CCMRx and CCER, if they are still set properly for input capture and enabled.

Check the GPIO and AFIO registers, if the given pin is still set to AF and there is no redirection.

JW

AKhor.1
AKhor.1Author
Associate II
Aug 31, 2021 4:13 AM UTC

I've used HaL code and the STM32cubeMX generated code. I have no idea about the registers.

 MX_GPIO_Init();
 MX_TIM1_Init();
 MX_TIM2_Init();
 MX_TIM3_Init();
 /* USER CODE BEGIN 2 */
 HAL_TIM_Base_Start(&htim2);
 HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
 HAL_TIM_IC_Start(&htim1, TIM_CHANNEL_1);
 HAL_TIM_IC_Start(&htim1, TIM_CHANNEL_2);

KnarfB
Super User
Aug 31, 2021 6:47 AM UTC

What @Community member​ ment: There is a SFRs tab in your above screenshot. This shows the registers in a tree view.