Ttelmah Guest
|
|
Posted: Tue Nov 28, 2006 5:03 am |
|
|
No generic answer.
It'll depend on your master clock frequency, and the PIC involved. Chances are that it is not possible. Timer0, in the 12/16 PICs, is only an 8bit timer, with a prescaler (assuming this is not already being used by the watchdog). As such available division rates from the master clock, are:
256
512....
in binary steps, up to
32768
The timer is fed from the incoming clock/4, so with a crystal frequency above (32768*4)/2, it is just not possible. Below this, it is still only possible from a 'binary multiple' clock. So it can be done from a master clock of 32768Hz, but not (accurately) from a clock of 20000Hz.
On the 18 PICs, this timer can be switched to 16bit mode, allowing higher frequencies to be used, but the same restriction of needing to be a 'binary' clock rate remains, for an accurate result.
Timer2, is the 'choice' for this type of timing, since it has the ability to have the division ratio of the timer itself programmed, getting away from the need for a binary master clock.
The alternative, is to feed Timer0, from an external binary clock, running it at perhaps 32768Hz (the commonest 'watch' crystal), while the main CPU runs at a fater rate.
Best Wishes |
|