mike50
New Member
The method you linked to gives you a "one second" interval that has zero error when averaged over many intervals. But any single "one second" interval can be off by as much as 255 microseconds (assuming you run with a 1:1 prescaler).blueroomelectronics said:Just noticed (yes I'm just finishing my morning coffee)
You're running the timer asynchronously (you're reloading it), this is not the way to do it.
https://www.romanblack.com/one_sec.htm
With the 16F628, it would be much better to use TMR2. Using TMR2 you can get an exact 1 second interval (well as precise as the oscillator being used). Using the 4MHz internal osciallator and by setting the TMR2 prescaler to 1:16, the postscaler to 1:10 and the PR2 register to 124 you get an interrupt every 20 milliseconds. After his CNT variable reaches 50 this gives exactly one second.
It is surprising that the internal oscillator is off by 5%, Microchip claims that it is accurate to 1%.
Mike