what is interrupt in microcontroller

what is interrupt in microcontroller

1 year ago 36
Nature

In a microcontroller, an interrupt is a signal that temporarily suspends the main program and immediately begins executing a different code, known as the Interrupt Service Routine (ISR), in response to some hardware event or software indicating an event that needs immediate attention. The ISR tells the processor or controller what to do when the interrupt occurs. Interrupts can be either hardware interrupts or software interrupts.

A microcontroller CPU is designed to respond to a number of different interrupt sources, and each source can have specific user-written code that executes when that interrupt triggers. The code that executes for an interrupt is called the ISR. For every interrupt, there is a fixed location in memory that holds the address of its ISR, and the table of memory locations set aside to hold the addresses of ISRs is called the Interrupt Vector Table.

In a microcontroller, interrupts enhance the use of microcontrollers by making programs react to the hardware of the microcontrollers, which may be a reaction from the circuit/environment outside of the microcontroller. Interrupts can be used to respond to a variety of events, such as a pin being driven low, a timer rolling over, or a key being pressed on a keyboard.

Interrupts can be enabled or disabled by setting bits of the IE register, and the whole interrupt system can be disabled by clearing the EA bit of the same register. When an interrupt occurs, the controller completes the execution of the current instruction and starts the execution of the ISR. The interrupts can be either edge-triggered or level-triggered.

One of the key rules for using interrupts is that they nearly always increase the unpredictability of the system. An interrupt can occur during any portion of code execution, literally between any two machine-level instructions, and asynchronous interrupts can all occur simultaneously.

Read Entire Article