...
A common example of a hardware interrupt is a GPIO interrupt, such as a user pressing a button and changing the state of the pin from HIGH to LOW. Another type of interrupt is a UART interrupt, where the program will stop itself upon receiving new input from the UART peripheral for you to deal with.
Application Notes
Your compiler doesn’t know when an ISR occurs, and thus may optimize out variables that are inside the ISR. Thus, it is important to understand the concept of the C keyword volatile, further reading can be found in my article here: Volatile
In an interrupt, your goal should be to get in, address what you need to as possible, and get out. The interrupt is NOT a place to be doing large amounts of computational power. Instead, set a flag for your code to read and to address. In an RTOS, a binary semaphore is a cheap way to do this.
Don’t try to print() in an ISR, it is a bad idea. Just don’t. Try it for yourself if you don’t believe me
...