There might be a race condition between the main loop and the interrupt. In any case, this code does not look like the example in figure 35 of the Programmer's Guide; please try that first.
↧