| ??? 12/30/03 23:12 Read: times |
#61634 - RE: Atomic 16bit read Responding to: ???'s previous message |
All you really care about is reading "dirty" data (i.e., the ISR corrupting your read main loop's read), so have the ISR set a "dirty" bit when it increments the 16-bit counter, then when the main loop wants to read the counter, it first clears the "dirty" bit, then reads the 16-bit counter and checks the "dirty" bit again. If the bit is set, it loops back around to clear the bit and re-read; otherwise, if the bit remained clear, you've got a clean read. This way you don't have to disable interrupts and only use one bit of overhead. The JBC instruction works here too. |



