Page 1 of 1

PIC Timer 0 as timer -- which clock speed is best?

Posted: Fri Jul 24, 2015 3:13 pm
by gtc
When using Timer 0 as a timer to count elapsed seconds as a 'background' process, I guess it's sensible to run the clock at a rate that minimizes the interrupts per second and thereby minimizes interference with the 'foreground' process, but which clock speed is best?

Given that the target chip (PIC16F88) has byte-only arithmetic, I will need to count timer overflows in multiples of 255. Accuracy is not absolutely critical in this application, nonetheless I would like the elapsed time to be as accurate as possible given the available clock and prescalar options available.

Here are the Interrupts Per Second rates for the PC16F88 using either 4MHz or 8Mh clock speed:

Code: Select all

   Clock->      4Mz        8Mz

Prescalar  
1:1          3906.250    7812.500
1:2           953.125    3906.250
1:4           976.563    1953.125
1:8           488.281     976.563
1:16          244.141     488.281
1:32          122.070     244.141
1:64           61.035     122.070
1:128          30.518      61.035
1:256          15.259      30.518
Environment

Chip: PIC16F88 (byte only, no float data type)
Timer: Timer 0
Mode: INTRC as Port I/O

Re: PIC Timer 0 as timer -- which clock speed is best?

Posted: Mon Jul 27, 2015 1:31 pm
by gtc
Anybody?

Re: PIC Timer 0 as timer -- which clock speed is best?

Posted: Mon Jul 27, 2015 1:45 pm
by Benj
Hello,

At 8MHz the 1:128 option seems to give you the least amount of error - 0.035

Or you could go for the 1:256 and alternate between counting up to 30 and counting to 31 to give 0.018 error.

Re: PIC Timer 0 as timer -- which clock speed is best?

Posted: Mon Jul 27, 2015 4:18 pm
by gtc
Benj wrote:Or you could go for the 1:256 and alternate between counting up to 30 and counting to 31 to give 0.018 error.
Great idea. Thanks.