The Pic Timer Calculator will calculate the real time period of the various timers associated with most of the PIC 16F series. No longer will you need to adjust and load a PIC with your code to get the timer periods right, the Pic Timer calculator will do that for you!
Instructions: 1. TIMER TYPE
Use the "Timer Type" drop down box to select the timer you wish to calculate. There are three Timers associated with the 16F series Pics and each one has different features. These features will appear as you select the required timer.
2. OSCILLATOR FREQUENCY
Set the "Oscillator frequency" by enetering the freq. in the box in megahertz. Frequencies accepetd are 0.000001 Mhz (1 hz) up to 999 Mhz. This is so that external clock frequencies of any value can calculated. The default setting is 4 Mhz.
3.TIMER OFFSET
The 3 timers,(Timer0, Timer1, Timer2) are all readable and writable timers. This means that you can load or offset a timer with a preset ammount, making the timer period shorter than default. i.e. timer 0 counts from 0 to 255, sets its rollover flag (which must be cleared in software) and counts again from 0 to 255. If you set the offset to, for example 100, the timer would count from 100 to 255, sets its rollover flag, you then load the timer in software with the offset and it counts from 100 again.The above example is for timer 0.Adjust the offset amount by moving the slider up or down with the up/down arrows for fine steps or the mouse.
4.LOW BYTE OFFSET / HIGH BYTE OFFSET
Timer 1 has two registers, low and high, making it a 16 bit timer. (counts from 0 to 65535). Both of these are readable and writable as per above in "Timer offset". By adjusting these values, very fine adjustments can be made to the timing algorithim. As above, these values have to be loaded in software. Adjust the offset amount by moving the slider up or down with the up/down arrows for fine steps or the mouse.
5. PRESCALER RATIO
All three timers have a pre-scaler. With the prescaler set to off or 1:1 the timer increments on every clock instruction cycle. With the prescaler set to, i.e. 4:1, the timer increments once for every 4 clock instruction cycles. This increases the timer period. Adjust the prescaler setting by moving the slider switch up or down.
6.POST SCALER RATIO
The post scaler is only available on timer 2. The post scaler operates on a similar principal to the above, but occurs after the timer has rolled over, and "post scales" the rollovers to the timer flag section. With it set to 4:1 for example, 4 "rollovers" would occur before the timer flag was set.This increases the timer period. Adjust the prescaler setting by moving the slider switch up or down.
7. PR2 OFFSET
Timer 2 has an 8 bit period register that is adjustable from 0 to 255. You can set this so that the timer counts up to the PR2 value, then rolls over.i.e. setting this to 100 , the timer would count from 0 to 100, then rollover back to 0.Adjust the offset amount by moving the slider up or down.
8. INSTRUCT CYCLE TIME
This displays the instruction cycle time and is dependant only on the Oscillator Frequency. Higher the frequency, quicker the instruction cycle time.
9. TIMER PERIOD
This displays the timer period result after setting/selecting the required parameters. Occurs instantly so you can see the effects of changing the register settings.
10. TIMER FREQUENCY
This displays the number of times the timer "flags" or "rolls over" per second. (i.e. hertz). This is usefull for working out accurate timer durations while adjusting the values.
11. HELP
Displays the help window with this text that you are reading now. Click again to hide the help window.
12. DISPLAY CODE EXAMPLE
Displays a sample of code that uses the settings that you have selected in the Pic Timer Calculator. This code can be cut and pasted into your Proton compiler.
13. DISPLAY CODE SETTINGS
Displays as code the settings that you have selected in the Pic Timer Calculator. This code can be cut and pasted into your Proton compiler.
14. QUESTIONANSWERS
Q.Timer 0 calculation is out by 2?
A. This is correct. In 16F series Pics, Timer 0 has a 2 count delay if written to or if the prescaler is changed. If this is a problem, adjust it by two in your code. Timer 1 & 2, as far as I can see, dont have this problem.
Q. The timers have different pre-scaler settings.Is this correct?
A. Yes, this is correct (check data sheets for the device you are using)
Stránky generuje redakčný systém e107, a údaje do neho nahadzujú EdizonTN a redaktori. Všetky zverejnené informácie si výhradne po dohode s administrátorom, dajte kam chcete.... Príspevky v diskusnom fóre a komentároch, vyjadrujú názory čitateľov. Redakcia serveru nenesie zodpovednosť za ich obsah. Vyhradzuje si však právo ich odstraňovať. (c) 2009-2019 Sledujte nás cez RSS, Twitter, Facebook, MeWe, Mastodon, Tumblr, Pinterest, alebo na YouTube . Verzia pre mobily