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.   
Also any code that accesses them needs to do so with interrupts turned off...  
otherwise you can wind up with corrupted values.   Imagine that the mainline 
code is accessing a multi-byte variable.  The code accesses the lower byte,  in 
comes an interrupt that changes the variable (new low and high bytes,  then the 
interrupt routine returns to the mainline code),  and then the mainline code 
proceeds to access the (now changed) high byte of the variable...  the 
resulting value is a mishmash of the old and new values.                        
                  
_______________________________________________
time-nuts mailing list -- [email protected]
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.

Reply via email to