I have a quick question which apparently isn't said online from what I've read: I know millis() on an Arduino doesn't change during a custom interrupt, but does the associated timer still counts in the background?
My program is time-sensitive and I would like to know if I should increase its value (how?) each time one of my interrupts is handled so that the main program's clock doesn't drift.
Thanks in advance, Regards, Mister Mystère
The CPU-internal timer will count even when interrupts are disabled. BUT when the timer overflows an interrupt is generated which will increment some counter in the library. If that interrupt is blocked for a long time ... then you will have a drift.
The CPU timer is hardware and not affected by any interrupt flags. Once it overflows the overflow bit is set / an interrupt is triggered. If interrupts are blocked at that time this interrupt will be queued. The queue size is 1, that is your must allow interrupts before the next interrupt is triggered. Since the timer overflows roughly once per millisecond you will need to ensure that you never block interrupts for longer than ~1ms.
Anyway you will have a drift since the Arduino's clock is not that precise at all. See my experiment on crystal deviations.