The interrupt mechanism is one of the most important features of a microcontroller. An interrupt is a signal to the processor emitted by hardware or software indicating an event that needs immediate attention. As code size increases and your application handles multiple modules, sequential coding would be too long and too complex. The interrupt mechanism helps to embed your software with hardware in a much simpler and efficient manner. In this topic, we will discuss how to implement a basic interrupt mechanism.
The AT89S8253 has a total of six interrupt vectors: two external interrupts (INT0 and INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt.
Each of these interrupts sources can be individually enabled or disabled by setting or clearing a bit in Special Function Register IE. IE also contains a global disable bit, EA, which disables all interrupts at once.
[fusion_imageframe image_id=”4604″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”none” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/03/extint-IE-1024×119.png[/fusion_imageframe]
EA bit enables or disables all interrupt sources (globally):
ET0 bit enables or disables Timer T0 interrupt:
TCON register is also one of the registers whose bits are directly in control of timer operation. The 4 bits in LSB is used for interrupt control.
[fusion_imageframe image_id=”4632″ style_type=”none” stylecolor=”” hover_type=”none” bordersize=”” bordercolor=”” borderradius=”” align=”center” lightbox=”no” gallery_id=”” lightbox_image=”” alt=”” link=”” linktarget=”_self” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” animation_type=”” animation_direction=”left” animation_speed=”0.3″ animation_offset=””]http://learn.openlabpro.com/wp-content/uploads/2018/03/Timer_TCON-1024×154.png[/fusion_imageframe]
IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2) EX0 = 1; // Enable EX0 Interrupt EA = 1; // Enable Global Interrupt Flag
void ex0_isr (void) interrupt 0 { // Interrupt subroutine for ext interrupt o P0=0xFF; // Turn on Port 0 for the interrupt Delay(2000); // Wait for some time }