cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 input capture ( CCR1 stays 0)

lukaskostorz9
Associate II
Posted on July 30, 2015 at 14:17

Hello

I generated code using CubeMX in order to measure a pulse (20µs - 100ms).

TIM2 is what I am using for that.

In the HAL_TIM_IC_CaptureCallback I am checking the value in the CCR1 register.

I am expecting that inside CCR1 the captured value will reside.

Unfortunately there is always the preload value as it was configured during initialization of TIM2.

Is there something I messed up? I assume that the timer is not counting at all.

Is there a way to proof this?
2 REPLIES 2
Posted on July 30, 2015 at 15:17

You could watch TIM2->CNT incrementing.

If it's not incrementing check the TIM2 APB clock is enabled.

If it's not capturing, and flaging a capture event, you'll have to check how it's configured, and if the external signal is present on the correct pin.

Not much detail to work with here.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Amel NASRI
ST Employee
Posted on July 31, 2015 at 12:38

Hi kostorz.lukas,

After code generation with CubeMX, what did you added to your main.c file?

CubeMX will only generate initialization code.

Refer to examples under ''STM32Cube_FW_F0_V1.3.0\Projects\USED_BOARD\Examples\TIM\TIM_InputCapture''.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.