What to avoid while writing ISR for interrupts
Interrupts plays a surprising role in a microcontroller program. And the ISR, Interrupt Service Routine is always ready to take the surprise challenge. But, ISR follows some guidelines and set of rules to properly execute the program. Recently I wasted my hours in the fight to get my desired output from the ISR. Then I found few rules which I m listing here. Here are a few DOs and DON'Ts for the ISR. We are here mainly concerned with Arduino.
DOs
- Make the ISR as short as possible
- Declare the variables used as 'Volatile'
- Don't use any delay() subroutine
- Don't use Serial.print()
No comments