I am very new to microprocessor programming and I need to take some timing information from a signal that switches between high and low. I am trying to use an interrupt and collect the time between the change but it saya in the reference that millis() will not work in the function for the ISR. Is there any other way I could get the timing info?
There is a problem. Well, it depends on the accuracy needed. The hardware counter could overflow after interrupts are disabled but before millis is called. The returned value will be off by up to the rollover amount (I believe it's 1 millisecond). The proposed fix is to check for the overflow in millis (as well as handling the overflow in the ISR).
There is a problem. Well, it depends on the accuracy needed. The hardware counter could overflow after interrupts are disabled but before millis is called. The returned value will be off by up to the rollover amount (I believe it's 1 millisecond)
Agreed that millis() won't update in an ISR but if you're only calling it once per pass through it's not a real issue in my mind.