![]() |
|||||||||||||||||
![]() |
|
Custom Search
Readers
comments
|
|||||||||||||||
A (midrange) PIC Timer guide.Do
you get stuck with PIC timer calculations juggling
between datasheet, calculator and your design requirements?
If so then you need some tools to automate the process. CalculationsTypically you will need to focus on the end result which is usually to make the timer generate a frequency or create a repeating interrupt time of the correct period. This is fairly difficult when you first have to find the information in the datasheet and then account for prescalers and postscalers etc.If you do this a lot you have quite a few calculations and decisions to make as the hardware in each timer is different and you'll also have to do battle with interrupts. TCL Scripts for PIC Timer calculationTo
make the process easy I have created three interactive script modules
written in TCL (Tool Command Language). These operate in a
similar way to a Java applets and they operate on-line.
Each of these scripts is geared towards the most typical use of each timer and lets you change prescaler, postscaler or register value using slider controls. This makes it easy to experiment with different values as the result is immediately displayed in the web page (frequency and period are displayed from each part of the timer e.g. after the prescaler, after the register, after the postscaler). So you can do what-if type operations (all without a calculator in sight) e.g. I need a 15ms repeat rate. From Timer 2 the closest I could get is 15.136 (took 1 minutes to test) - perhaps I'll try timer 1 - Ah that gives an exact 15ms (took 30 seconds to test). Just check with Timer 0 - this gives 15.040ms (took ~30 seconds to test). Of course you can also set the main clock frequency (internal or external crystal) as well. PIC Timer 0This has an 8 bit prescaler and an 8 bit timer and can be driven from an external clock.Prescaler : 8 bit Timer register : 8 bit Link to PIC-Timer 0 calculator. PIC Timer 1
This has a 4 bit prescaler and an 16 bit timer and
can be driven from an external clock. It can also be driven from a slow
speed crystal e.g. 32kHz. |
|||||||||||||||||
|
|
|||||||||||||||||
|
|||||||||||||||||