Millis() stops increasing at a specific number

I am working on a project that takes in a series of pulses, so I put an interrupt on the falling edge of each pulse. For ease, I just inputted a 200Hz square wave with a 50% duty cycle and Millis() stopped outputting anything more than 2635. Any ideas why?

Image from Reply #NN Original Post so we don’t have to download it. See this Simple Image Guide



Please don’t post pictures of text - as you can see it is unreadable. Just copy and paste text.

Also post the program that is causing the problem.


Also, if you’ve read any other posts on interrupt behaviour, you know the basic rules within an isr().

Do not print things in an ISR.

Particularly when you are expecting pulses at 200hz, but in the ISR you're printing ~5 characters per pulse at 9600 baud.

That means ~10ms per character, so 50ms per pulse, when pulses are coming in every 5ms.

Once the serial buffer fills, Serial.print() becomes blocking, so each of those ISRs is taking 50ms to run - by which time the interrupt is triggered again, and it has higher priority than the timer interrupt that increments millis(), so that never runs, and millis stops incrementing.

Serial.print() should not be used in an ISR, and you need to be aware of how long serial output takes to send (especially at such a low baud rate).