When you use interrupts, there are a couple of things that you should keep in your mind.
-
You should keep the ISR (interrupt service routine) as short as possible.
-
Avoid blocking functions, like delays.
-
Avoid serial prints.
-
Avoid non-reentrant function calls.
-
Don’t declare any non-static variables inside the handler.
-
Avoid operations that involve dynamic memory allocations.
You can search the web for more details.