Technosvitman wrote:
I encountered the same problem. You must declare the variable volatile. Otherwise, it is impossible to access in the context of the interruption and in the context of normal program.
The only thing that needs to be
volatile is the variable 'timestamp' because it is changed outside the scope of the subroutine. It isn't impossible to access it, the problem is that the optimizer, if enabled, will/might try not to read it every time because it assumes it's value is static, when in fact it needs to be read at each loop iteration because it might have changed.