Quote:
|
Originally Posted by Orborde
In order to ensure that the read operation on an timer+interrupt-driven clock counter variable doesn't get messed up, instead of disabling ALL interrupts, I decided to simply shut off the timer, do the read, and then turn it back on. This should keep the clock counter variable safe while allowing other interrupts to jump in and do their thing during the clock read. Is this insane?
|
In a word (and in my opinion): yes.
The clock read itself takes less time than an interrupt service routine. Disabling interrupts doesn't ignore them completely; it just defers them until they are reenabled. If you turn off the timer, you lose time; your counter variable runs slow. The more often you read it, the slower it gets.