I was just wondering why the delay function would not work as it should when used within the TIMER1 ISR? I put a 5s delay before initializing TIMER1 and set up pin13's LED to blink with 1s delay between on and off. The 5s delay before initializing works as it should but the delay in the ISR is much shorter. I found with prescaler of 1024 the delay is 64x slower, I need to put delay(64000) for a 1s delay?
interrupts are disabled when an ISR is entered, then reenabled upon exiting the ISR.
delay uses interrupts to track time passing. No interrupt, no time,
what chip are you using? There are a few cores for some chips that use timer1 instead of timer0 for millis (some tiny85 cores are like that)
where is your code? I'm not sure exactly what you're doing.
Are you trying to use delay() inside an ISR? Don't do that - delay() is interrupt driven, so I suspect that it's not working because you're in an interrupt already and a key interrupt is disabled. ISRs should return as quickly as possible - no 5 second delays, no 5 milliseconds. Set a couple variables and return, then check for that in your main loop.
If you need an action to occur a number of milliseconds after an interrupt has happened then the ISR should record the millis() when the interrupt occurs and the main loop should look at that variable to decide when to do the action. Don't try to wait even a microsecond inside the ISR.
MorganS:
Don't try to wait even a microsecond inside the ISR.
Repetition, just in case the point was missed.
Interrupts are for things that need to happen quickly and the code in them should finish as soon as possible so that other activities are not disturbed.
...R