cancel
Showing results for 
Search instead for 
Did you mean: 

Reading timer counter & prescaler on the fly - STM32F205RBT6

aamirali641989
Associate II
Posted on July 19, 2014 at 13:47

I am using STM32F205RBT6.

I have to start a timer when a particular event happens. This I have done in programming.

After that interrupts comes on three other pins. Now I have to measure the time between:

1. Start & interrupt on pin 1 

2. Start & interrupt on pin 2

3. Start & interrupt on pin 3

1. Can I read the value of counter & timer on the fly so that I can measure time?

2. If answer is yes, then I think there is some error in it. Like when interrupt happens on pin then control will first go to external pin ISR, where I will read timer values. In this error may come ? Can I reduce this error?

3. Is there any better method to do this?

3 REPLIES 3
Posted on July 19, 2014 at 14:51

You can read TIMx->CNT, or have the pin transition latch the event in TIMx->CCRx

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
aamirali641989
Associate II
Posted on July 29, 2014 at 18:42

Thanks clive for your reply.

But I have 3-10 such stop pulses come.

But CCRx register has only one or ttwo pins with it. then what would be best way to do that

Posted on July 29, 2014 at 18:50

Most timers have 4 channels, and can latch events on four pins.

If the counter is free running

Input Capture is the equivalent of

  TIMx->CCRx = TIMx->CNT; // At the event

You can back out the interrupt latency by reading TIMx->CNT in the handler. ie current value, vs value latched at the edge.

For PWM Input mode, or resetting the timer, then you'll likely need one timer per input signal.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..