[time-nuts] First success with very simple, very low cost GPSDO, under $8
holrum at hotmail.com
Wed Apr 9 01:44:15 EDT 2014
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.
More information about the time-nuts