BobaMosfet
- Joined Jul 1, 2009
- 2,113
No, most interrupts are NOT triggered by peripheral devices. That is just a capability of the MCU. Interrupts are the very life-blood and heart of timing and task processing in any operating system.Most embedded systems use interrupts, which are typically triggered by some peripheral device. In a lot of interrupt tutorials/examples, it always says that ISR code must be kept short
Why Short Interrupt Service Routines Matter?
Why don't we just create the whole system on interrupts and make the main loop sleep?
Short ISRs are directly related to the amount of time it takes to execute the code in the interrupt versus when that same interrupt is going to fire again. Obviously, you want to complete your task in the time given, and not run beyond it. If you run beyond your available time slice, that interrupts fires again, parking your code, starting the new iteration, and so on- this will consume the stack-frame and memory becuase your tasks aren't completing fast enough.
Most developers do NOT have experience working in interrupt driven systems. They are used to a linear progression of their code, and are not familiar with the additional coding aspects necessary to make code re-entrable, or prevent it from being re-entered in an interrupt-driven system so that things work homogeneously. If you aren't familiar with how to actually develop in such an environment, you can create logic errors in your code that you cannot figure out.