cancel
Showing results for 
Search instead for 
Did you mean: 

How ARR value impact on timer input capture result?

HB
Associate II

Hello guys,

I have just started working with stm32 controllers. I am trying to capture the frequency of signal using timer 2 input capture mode.

I am getting absolutely correct frequency if i use ARR = 65535 but when i use ARR = 0xffffffff (As timer 2 is 32bit) i am getting wrong result.

I am using this reference equation

Frequency = TIM_CLOCK / ((C2-C1)*(prescaler+1))

Where C2 = capture value 2 // Both Rising edge

C1 = capture value 1

TIM_CLOCK = 1Mhz

TIMER_PSC = 16-1

SYSTEM_CLOCK = 16Mhz

Please help if i am missing something.

26 REPLIES 26

After you've set PSC and ARR, e.g. somewhere between steps 5 and 8, do

TIM2->EGR = TIM_EGR_UG;

JW

Yes i did but still not working.

I think update event generation is only required if i change ARR/PSC after the timer has started.Here in my code i am setting both before i start timer.

> I think update event generation is only required if i change ARR/PSC after the timer has started

No.

JW

Okay. I have tried it still not working.

Post code you have tried (exactly that code, copy/paste) and numbers.

JW

It is working. Bymistake i wrote TIM1->EGR instead of TIM2->EGR.

Thank you very much for your time and efforts.