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.

  • What pin is it? Why not use attachInterrupt and detachInterrupt? – Nick Gammon Feb 14 '16 at 20:55
  • The code is inside a function. attachInterrupt only works for two pins. – Vasil Kalchev Feb 14 '16 at 20:57
1

Don't you mean:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.