Serial.print messing with Timer Interrupts

I can't really explain it.

If you were doing the Serial prints inside an ISR, yes it would be explained. But you don't appear to be doing that.


BTW I would use the variable "max" with caution as max is defined in Arduino.h:

#define max(a,b) ((a)>(b)?(a):(b))

Without the parentheses you get away with it, but it is a bit dubious.


I conclude that this looks like a bug in my code and the ISR seems to work fine. However this would imply that adding the prints somehow makes my code glitch.

Perhaps you are altering some global variable you forgot about?