Page 1 of 1

Timer 2 Calculator

Posted: Tue Mar 10, 2020 7:09 pm
by medelec35
I prefer using timer 2 over other timers as it allows much more precise control.
That is because you have a Postscaler, Prescaler and a rollover value to deal with.
While having more options gives you much better flexibility, it's downfall is its more complicated to calculate correct values to give desired frequency.
For example, I'm after an interrupt hat gives me exactly 60Hz, how do I determine the correct Postscaler, Prescaler and Rollover values?
That is where the attached Excel sheet comes in extremely handy.
Just enter the oscillator frequency and required interrupt frequency and the Excel sheet gives all the answers!
Timer 2 Calculator.png
(85.74 KiB) Downloaded 1936 times
Timer 2 Flowcode.png
(37.22 KiB) Downloaded 1936 times
As you can see if maximum prescaler is only 16 then the nearest value to 60 will be 75Hz.
How about I would like to know all the whole frequency values?
Not a problem, excel sheet can do that as well:
Timer 2 Calculator whole freq.png
(135.29 KiB) Downloaded 1936 times
Hope this helps you as much as it has helped me.
The Excel sheet was modified with Libra Office, but I see no reason why it won't work with excel.
Note: After entering frequency you must select the drop-down and what maximum Prescaler you have, before results are shown.

Re: Timer 2 Calculator

Posted: Wed Mar 11, 2020 10:24 am
by medelec35
V2 shows a more instant values without having to select drop-down filter.
Timer 2_Calculator V2 Instant View.png
(43.93 KiB) Downloaded 1904 times
Also, selection bug fix.

Re: Timer 2 Calculator

Posted: Mon Mar 16, 2020 8:01 pm
by Steve001
Thanks Martin

Appears to work ok with Apache open office

Steve

Re: Timer 2 Calculator

Posted: Wed Dec 02, 2020 9:43 pm
by medelec35
Just saved with microsoft office.
Libra Office version was not working with excel 365