PIC TIMER CALCULATOR
Beta Version 1.0
INTRODUCTION
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!
To install,
download the PicTimerCalcV1.zip and unzip to a directory named
"PicTimerCalc" or a directory of your choice. To run the program,
click on PicTimerCalcV1.exe in your unzipped folder or directory.
Addendum Version 2
now ready for testing.
Dowload File : PicTimerCalcV2.zip
The program was
written using Easy Tools (a scripting tool, similar to basic).Easy Tools is
fantastic for building graphical user interfaces for communicating with pic
chips. Check out the site http://www.easyvitools.com/index.html
The program does
not create any "*.dll" files or modify the windows registry and only
takes up 1.5 Mb of disk space. To remove the calculator, just delete the directory
you downloaded it to.
NB. This is the
beta version of this tool. If you find any errors or mistakes please let me
know by contacting HighcoPic on the Proton forum. Please dont distribute until
all its mathematics are proven to be correct!
Have fun, let me
know what you think!
USER INSTRUCTIONS:
Contents:
1. Timer Type
2. Oscillator
Frequency
3. Timer Offset
4. Low/High Byte
Offset
5. Prescaler Ratio
6. PostScaler Ratio
7. PR2 Offset
8. Instruct Cycle
Time
9. Timer Period
10.Help
11.Display Code Example
12.Question\Answers\Problems
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.
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 algorithm. 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 pre-scaler 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 pre-scaler 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 pre-scaler 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. HELP
Displays the help window
with this text that you are reading now. Click again to hide the help window.
11. DISPLAY CODE
EXAMPLE
This is not yet
complete in this version, but my intentions are to display an example of code
with the settings you have made!
12. QUESTION\ANSWERS
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, don’t 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)
Q. When will the
"display code example" button work?
A. Soon........!