Interrupts (Week 2) Flashcards
Interrupts
An interrupt causes the normal program execution to halt and for the interrupt service routine (ISR) to be executed.
A device (like a button, sensor, timer) sends a signal to the microcontroller on a wire called interrupt request line. The microcontroller will pause the current program and preform an interrupt service routine (ISR), then will continue from where it left off.
Interrupts vs polling
Interrupts tell the microcontroller when it needs attention. (only happens when needed), it will go off when something changes, and the microcontroller pauses and in the ISR it will handle the event (so like read the sensor, reset a timer, store data), then continues
- All code is in one place
Polling - Repeatedly checking the status of inputs (To see if something changed)
- uses a lot of horsepower
-Messy code
- takes longer
Interrupt Flags and Enabled Bits
- Interrupt Flag bit- Set whenever an interrupt event occurs (Means an event happened)
- Interrupt Enabled bit- indicates weather the microcontroller should respond to the interrupt when its triggered (Means WE told the microcontroller we care about this event so respond when uit happens)
Both these bits are required for an interrupt request to be generated