Writing a Safe ISR
Keep interrupt handlers short and use volatile.
A Special Function
An ISR, or interrupt service routine, is the function that runs when an interrupt fires. It has rules that ordinary functions do not.
Keep It Short
The golden rule: make your ISR as short as possible. The main program is paused while it runs, so finish fast and get out.