cancel
Showing results for 
Search instead for 
Did you mean: 

timer overflow interrupt

pedropbr
Associate II
Posted on November 13, 2010 at 00:51

timer overflow interrupt

12 REPLIES 12
Posted on May 17, 2011 at 14:14

I have to measure how many clocks (periods) I have during 1s.

 

The nominal clock is 25Mhz.

 

I have to measure it using the GPS 1PPS as reference to check the real clock.

 

Basically an A-B measurement counting ticks of your 25 MHz clock.

Well 16-bits is going to suck for that. 65535 Hz (15 us), you'd be better interrupting off the 1PPS and reading the 32-bit counter in the core running off SYSCLK.

You could use a Flip-Flop on the 1PPS, and use that to gate the timer, and measure the period of every other second. If you need every second, take the inverted output of the flip-flop and have it gate a 2nd timer. Have the timers set to tick at say 50 KHz.

What kind of accuracy are you looking for? Using the high priority interrupt method might get you sub-microsecond.

I've used GPS to look at the HSI (8 MHz) and LSI (40 KHz), neither are particularly stable. For the 32/40 KHz you can use a smaller prescaler to the RTC counter so it ticks quickly, and again check that on the 1PPS interrupt.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pedropbr
Associate II
Posted on May 17, 2011 at 14:14

Hi. Thank you for helping me.

I've set it up successfully using the Input Capture mode. It detects the rise edge of the gps 1pps and interrupts. By the way i've set 2 interrupts: 1st to count buffer overflows and 2nd to detect the rising edge of the 1pps.

I'm using TIM3 and after each overflow my program increments a variable ''i''. In the end, I get 1099 overflows + 40000 periods. So:

1099*65536 + 40000 = 72,06Mhz

But TIM3 is connected to APB1 and it's maximum speed is 36Mhz. Do you know how to solve it?

Posted on May 17, 2011 at 14:14

But TIM3 is connected to APB1 and it's maximum speed is 36Mhz. Do you know how to solve it?

Check the clock tree diagram again, and look at how it forks the timer clocks.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..