2

I am using the following code to enable an interrupt for a pin:

*digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin));  // enable pin
PCIFR  |= bit (digitalPinToPCICRbit(pin)); // clear any outstanding interrupt
PCICR  |= bit (digitalPinToPCICRbit(pin)); // enable interrupt for the group

But I can't disable it. I am trying with this code:

if (*digitalPinToPCMSK(pin) == 0)
*digitalPinToPCICR(pin) &= ~(1<<digitalPinToPCICRbit(pin));

but it isn't working.

2
  • What pin is it? Why not use attachInterrupt and detachInterrupt? Commented Feb 14, 2016 at 20:55
  • The code is inside a function. attachInterrupt only works for two pins. Commented Feb 14, 2016 at 20:57

1 Answer 1

1

Don't you mean:

  PCICR  &= ~bit (digitalPinToPCICRbit(pin));
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.