RTCZero icon indicating copy to clipboard operation
RTCZero copied to clipboard

Interrupt not unattached

Open fabltd opened this issue 8 years ago • 1 comments
trafficstars

I am trying to use the RTC Alarm to trigger a Serial Event.

When the Alarm RTC is Matched the serial function is called.

The serial function contains delays. I understand these interfere with interrupts.

I have tried to disable the interrupt rtc.detachInterrupt(); before running the serial function but it still crashes the zero.

I have tried to replace the delay with a millis timer but its still crashing.

The serial function works fine in all other aspects of the program its only when its called by the RTC Alarm does the zero crash.

HELP!!

fabltd avatar Jan 25 '17 13:01 fabltd

It's best to keep interrupt service routines short and sweet. Serial output works in a timer ISR for me, but delays are a no-no, and using other timers probably problematic. The usually way to handle this is to create a global flag to signal when the timer has fired, a la:

static bool timerFired = false;

void timerISR()
{
  timerFired = true;
}

void loop()
{
  ...
  if (timerFired)
  {
    timerFired = false;
    // All the code you ripped out of the ISR goes here
  }
  ...
}

softweyr avatar Jan 27 '17 20:01 softweyr