hol...@hotmail.com said: > I'm not sure how the Arduino environment handles interrupts, but in C you > need to declare any variables altered by an interrupt as "volatile" so that > the compiler optimization routines know not to assume they contain known > values.
Good point. > Also any code that accesses them needs to do so with interrupts turned > off... otherwise you can wind up with corrupted values. Not quite. That may be the simplest way, but you can also use inter-process communications type tricks. The classic for a two byte counter is to read high-low-high and try again if the high values don't match. That assumes the interrupt routine updates low then (maybe) high. -- These are my opinions. I hate spam. _______________________________________________ time-nuts mailing list -- time-nuts@febo.com To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts and follow the instructions there.