attachinterrupt

Is it possible to use "attachinterrupt" to monitor for both the rising and falling of a signal on 1 digital input pin, using seperate isr's for each condition? I have been trying to do this to monitor the run time of a burner but it only seems to be responding to 1 of the interrupt requests and not both.

attachInterrupt(digitalPinToInterrupt(burner_monitor), start_timer, RISING);
attachInterrupt(digitalPinToInterrupt(burner_monitor), stop_timer, FALLING);

void start_timer () {
(start_time = millis ());
return;
}
void stop_timer () {
stop_time = millis ();
burner_runtime = (burner_runtime + (stop_time - start_time));
return;
}

I don't believe you can do it like that. Just use a CHANGE interrupt and within the ISR detect whether the new state of the pin is HIGH (it was rising) or LOW (it was falling).

It may be helpful to use the digitalWriteFast library (which also has a ...Read... function) for increased performance.

...R

So you think you can only attach 1 interrupt to a single digital input. Is this correct?

Yes, that is correct. Only one interrupt routine.

Ken_F:
So you think you can only attach 1 interrupt to a single digital input. Is this correct?

If you think about it ... attachInterrupt() is a single thing with 3 flavours

...R