> But if interrupt latency is an issue, you can use a > different method: have the ISR put the 32-bit > integer into a temporary holding register and set a > flag bit somewhere to indicate to the > main code that a new integer value is available. > The main code can test the flag and when a new > value is available, transfer it > to the working variable and then reset the flag. > The ISR, in turn, refrains from updating the > holding register unless the flag has been cleared > by the main code. There were lots of good explanations for why this works, but here's different take. Just consider this a special case of two-process mutual exclusion where the processes (ISR and main) proceed in strict alternation: ISR --- while (turn != ISR); turn = main; main ---- while (turn != main); turn = ISR; The flag "new integer available" is equivalent to variable "turn", and the critical section is where "holding register" and "working variable" (and anything else you would like to access atomically) are manipulated. __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body