Hi,
Sure, it makes sense. If you need accurate timing you'll have to resort to a timer based interrupt. However, if timing isn't that critical you can set up the hardware timer and just check the interrupt flag in software (ie. not actaully enabling the interrupt).
You can use TMR1 of the 12F675, with a 1:8 prescaler and 4Mhz clock it will overflow at a rate of (4000000/4/8/65536) = ~1.9Hz. Unfortunately the highest prescaler ratio is 1:8 so that's as "slow" as it gets. Having it "time" 20 seconds intervals would require an external clock x-tal for the timer oscillator which would cost you two I/O pins that you don't have.... :-(
For accurate timing, as already been said, you'll have to resort to an interrupt based routine. In this case you set up the timer so it overflows at a rate high enough for your timing purposes, lets say 100Hz. Then you keep track of the time pretty much as you already did - with variables like Days, Hours, Minutes, Seconds, ms.
Have a look at Darrel Taylors Elapsed Time routine I think it pretty much fits your need perfectly.
/Henrik.
Bookmarks