I'm trying to use an ATTiny84's INT0 pin to detect a falling edge event on a 1 kHz signal.
What is the correct way to temporarily halt this interrupt INT0, and then resuming it at a later time, without skewing its response time?
I'm having difficulty halting the interrupt, performing a time-consuming operation, and then resuming the interrupt. Afterwards the interrupt's response seems to have drifted very badly from its original position.
I've been using cli()
to stop it, and sei()
to restart it, but this seems not to work reliably. Is there a better way?
If I do not perform any halt and restart of the interrupt, then the ISR performs solidly and in lock-step with the 1 kHz signal flawlessly. If I do halt, pause for a while and resume the interrupt it seems to "remember" that it needs to call the ISR at an unpredictable moment and loses sync with the 1 kHz signal and never regains sync.
GIFR = 0xff;
fixes the problem. Is this register still active even aftercli();
is called? \$\endgroup\$