How to disable and anable this function "attachInterrupt"

How to disable and anable this function "attachInterrupt" when when i call the action server.on("/update", HTTP_POST, .

  attachInterrupt(digitalPinToInterrupt(buttonPin), pulseCounter, RISING);//

server.on("/update", HTTP_POST, []() {
server.sendHeader("Connection", "close");
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
ESP.restart();
}, []() {
      HTTPUpload& upload = server.upload();

});

example :
 if(update )
{
  attachInterrupt(digitalPinToInterrupt(buttonPin), pulseCounter, RISING);// Desable
}else{
  attachInterrupt(digitalPinToInterrupt(buttonPin), pulseCounter, RISING);// enable

Use detachInterrupt()

Thanks for the help but I'm getting this message.
too many arguments to function 'void detachInterrupt(uint8_t)'

It only takes one argument.
detachInterrupt(digitalPinToInterrupt(buttonPin));

1 Like

Detaching / Re-attaching the interrupt may not be the best way to do this. Sounds like it could be an XY problem. What do you really need to do and why?

1 Like

See:
" https://deepbluembedded.com/arduino-nointerrupts-sei-cli-functions/

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.