??? 07/25/05 21:12 Read: times |
#98095 - timekeeping Responding to: ???'s previous message |
the only way to keep reasonably precise time is auto-reload No, this is the comfortable, easy, fast, but sometimes not suitable way (especially for derivatives with timers 0 and 1 only). For "manual" reloading, the reload value can be compensated for the ticks elapsed from timer overflow to the moment of reloading (to accomodate interrupt latency). See Peter Dannegger's webpage for an example. A "trickier" and easier way (but also not always suitable) is to chose the reload value so that it is an integer multiple of 256 or 32 (the latter for mode 0). Then it is simply enough to reload THx at the beginning of timer isr, where the already elapsed ticks since overflow don't cause THx to be already incremented. Jan Waclawek |