8051 Interrupts Final
8051 Interrupts Final
8051 Interrupts Final
8051 – Interrupts
• Microcontrollers must provide real time (predictable, though
not necessarily fast) response to events in the embedded system
they are controlling.
• A interrupt is a signal that stops the current program forcing it
to execute another program immediately.
• The interrupt does this without waiting for the current program
to finish.
• It is unconditional and immediate which is why it is called an
interrupt.
• An interrupt is the occurrence of an event that causes a
temporary suspension of a program while the condition is
serviced by another program.
– Allow a system to respond asynchronously to an event and
deal with the event while another program is executing.
8051 – Interrupts
• An interrupt driven system gives the illusion of doing many
things simultaneously.
– Of course, the CPU cannot execute more than one
instruction at a time.
• It can temporarily suspend execution of one program,
execute another, then return to the first program.
– In a way, interrupts are like subroutines. Except that one
does not know when the interrupt code will be executed.
Interrupts vs. Polling
• Polling:
– CPU monitors all served devices continuously, looking for a
“service request flag”
– Whenever it sees a request, it serves the device and then
keeps polling
– CPU is always “busy” with polling doing the “while any
request” loop
• Interrupts
– If and when a device is ready and needs attention, it informs
the CPU
– CPU drops whatever it was doing and serves the device and
then returns back to its original task
– CPU is always “free”, when not serving any interrupts
Interrupt Service Routines
5
Interrupt Execution