This is for people who using timer0 would like microcontrollers to interrupt at different frequency to those available.
E.g your microcontroller speed is 4MHz and you required an interrupt frequency of 1000Hz. You look at properties of interrupt to discover you only can have an interrupt at 976.53Hz with prescaler set at 1:4 or and interrupt at 1953.125Hz.
With attached calculator,It will show how to get that desired interrupt frequency to set at 1000Hz.
It won't work on all cases. This is because timer offsets can only have a whole number between 0 and 255 and the calculation result could be 120.53 for instance, and you can only enter 120 or 121 for offset. For that reason I have also included in the calculator offset if not a whole number and frequency of interrupt generated with the calculated offset since there are times these won't match 100%.
Hope this would come in useful. I created calculator for my new project, but I'd thought I'd share it.
Note: May sound obvious. But two points.
1) Calculator created in excel 2007, so if opened on a version prior to 2007, then colours will vary form attactached image.
2) All text within light grey areas are user inputs. All text within purple areas are calculated results.
Interrupt Frequency Calculator and Timer Offset Calculator
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Interrupt Frequency Calculator and Timer Offset Calculator
- Attachments
-
- Int time CalulatorV1.xls
- (51.5 KiB) Downloaded 868 times
Martin
-
- Posts: 714
- Joined: Wed Jan 31, 2007 12:41 pm
- Has thanked: 1 time
- Been thanked: 26 times
- Contact:
Re: Interrupt Frequency Calculator and Timer Offset Calculator
Hello medelec35
Why,your calculator stopp at 20 000 000MHZ?
Regards wolfgang
Why,your calculator stopp at 20 000 000MHZ?
Regards wolfgang
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Interrupt Frequency Calculator and Timer Offset Calculator
I use a data list validation base on values in Flowcode. That stops as 20MHz
My intention was to use any values but that did not happen.
Try this one, any Frequency can be entered.
My intention was to use any values but that did not happen.
Try this one, any Frequency can be entered.
- Attachments
-
- Int time CalulatorV3.xls
- (68 KiB) Downloaded 657 times
Last edited by medelec35 on Thu Aug 20, 2009 6:39 am, edited 2 times in total.
Martin
Re: Interrupt Frequency Calculator and Timer Offset Calculator
Hello medelec35,
that's great thank you for release.
that's great thank you for release.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Interrupt Frequency Calculator and Timer Offset Calculator
you welcome. Hope it comes in handy. If chip frequency is 4 or 8Mhz, it will make timing more accurate.
Good luck.
Good luck.
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Interrupt Frequency Calculator and Timer Offset Calculator
V3. Added Useful list of Interrupt frequencies produced for all Timer offset values from 0 - 255 at the set prescaler rate.
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Interrupt Frequency Calculator and Timer Offset Calculator
V4.
Added extra columns to calculate variable value required in interrupt macro for a given time delay. Untested. Comments for improvements or usability are welcome. Perhaps comments on the maths please, i.e. how accurate calculations are.
Thanks.
Added extra columns to calculate variable value required in interrupt macro for a given time delay. Untested. Comments for improvements or usability are welcome. Perhaps comments on the maths please, i.e. how accurate calculations are.
Thanks.
- Attachments
-
- Int time CalulatorV4.jpg (73.34 KiB) Viewed 14097 times
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Interrupt Frequency Calculator and Timer Offset Calculat
V5
Some minor cosmetic improvements.
Improve accuracy on updating timer values, thanks to sean for saying about += instead of just =.
Calculator on the right loads with same Osc Freq and Prescaler as entered on the left, so less data to enter.
Notice you can use calculator if require;
A interrupt frequency e.g 80Hz
or
A specific time delay using interrupts eg 300 seconds.
Also if require a particular delay, then delay given for all timer offsets (0-255)
Some minor cosmetic improvements.
Improve accuracy on updating timer values, thanks to sean for saying about += instead of just =.
Calculator on the right loads with same Osc Freq and Prescaler as entered on the left, so less data to enter.
Notice you can use calculator if require;
A interrupt frequency e.g 80Hz
or
A specific time delay using interrupts eg 300 seconds.
Also if require a particular delay, then delay given for all timer offsets (0-255)
- Attachments
-
- Int time CalulatorV5.xls
- (94 KiB) Downloaded 830 times
Martin