cancel
Showing results for 
Search instead for 
Did you mean: 

Why time input capture does not work continiously?

AKhor.1
Associate II

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.

5 REPLIES 5

Read out and check/post content of TIM registers.

JW

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

0693W00000DlYc5QAF.jpg

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

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
Principal III

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