Interrupt Frequency Calculator and Timer Offset Calculator
Posted: Sat Aug 15, 2009 6:08 pm
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.
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.