microcontroller - INTERRUPTS
Interrupt means, stopping the main program loop or operations due to allowed / programmed change, then go for some operations to perform, again continue the main program. Interrupt is one of the most required feature in micro-controllers.
INTERRUPT - WORKING CONCEPT:
Normally micro-controller programs are written to do sequential operations, out of which, most of the operations are framed in a loop to do specific operations. The output depends on the input of signals from sensors or other electronics equipements.
But, some operations depend on a particular signal, which is indepenent of the time or position of normal input or output operations. In this situation an INTERRUPT is generated and corresponding bit in the particular Registar is set (to high or low), which is called interrupt flag is set.
Once Interrupt Flag is set, the Processor inside the micro-controller saves the current status of operations to separate registers (called as Push to Stack) and calls (or loads) the particular function related to the interrupt is caused, which is called INTERRUPT SERVICE ROUTINE.
Now, the processor works on the operations / instructions written in the function, then returns to the main program on completion and resets the interrupt flag (=off). Now, the processor calls back the previous values saved to the specific registers (called as Pop from Stack) and continues its normal operations.
CAUSE OF INTERRUPT:
Interrupt may be caused by so many reasons, which are set by the programmer (by you) as required. Interrupts are of two types. 1) External 2)Internal.
Some of the pins of micro-controller serve the purpose of Interrupt Input pins. By setting the related bits in the Interrupt register, the relative interrupt is activated. The interrupt may be caused by changing the voltage level to high or low or toggle at the external pins, as per the bits set in the interrupt register by the programmer.
Internal Interrupt may be caused by the reasons set by the programmer. Most of the internal interrupts caused by Timers , Counters , ADC , Communications etc., which are set by the programmer as per requirement.
This is the general concept about Interrupts. The allowed functions and names of routines of Interrupt service routine depends on the specific micro-controller.
ALL THE BEST TO YOU.