0% found this document useful (0 votes)
26 views

Interrupts Programming

The document discusses interrupts in the 8051 microcontroller. It describes the six interrupt sources in the 8051 - reset, two timers, two external hardware interrupts, and serial communication. It explains the steps in executing an interrupt, including saving context and jumping to the interrupt service routine. It also covers enabling and disabling interrupts through the interrupt enable register and priority among different interrupt sources.

Uploaded by

irfan_kembhavi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Interrupts Programming

The document discusses interrupts in the 8051 microcontroller. It describes the six interrupt sources in the 8051 - reset, two timers, two external hardware interrupts, and serial communication. It explains the steps in executing an interrupt, including saving context and jumping to the interrupt service routine. It also covers enabling and disabling interrupts through the interrupt enable register and priority among different interrupt sources.

Uploaded by

irfan_kembhavi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

oINTERRUPTS

PROGRAMMING
 8051 interrupts
 Steps in executing an interrupt
 Six interrupts in 8051
 Enabling and disabling an interrupt
 Programming timer interrupts
 Programming external hardware
interrupts
 Programming the serial communication
interrupts
 Interrupts priority in the 8051
1/7/2011 1
o8051 interrupts
• Interrupt is an external and internal event
that interrupts the microcontroller to inform
it that a device needs it service.

1/7/2011 2
oSteps in executing an interrupts
1) IT FINISHES THE INSTRUCTION IT IS EXECUTING AND SAVES THE ADDRESS OF
THE NEXT INSTRUCTION ON THE STACK.
2) IT ALSO SAVES THE CURRENT STATUS OF ALL THE INTERRUPTS INTERNALLY.
3) IT JUMPS TO A FIXED LOCATION IN MEMORY CALLED THE INTERRUPT VECTOR
TABLE THAT HOLDS THE ADDRESS OF THE INTERRUPTS SERVICE ROUTINE.
4) THE MICROCONTROLLER GETS THE ADDRESS OF ISR FROM THE INTERRUPT
VECTOR TABLE AND JUMPS TO IT . IT START TO EXECUTE THE INTERRUPT
SERVICE SUBROUTINE UNTIL IT REACHES THE LAST INSTRUCTION OF THE
SUBROUTINE WHICH IS RETI.
5) UPON EXECUTING THE RETI INSTRUCTION , THE MICROCONTROLLER RETURNS
TO RETURNS TO THE PLACE WHERE IT WAS INTERRUPTED . FIRST ,IT GETS THE
PROGRAM COUNTER ADDRESS FROM THE STACK BY POPPING THE TOP TWO
BYTES OF THE STACK INTO THE PC . THEN IT STARTS TO EXECUTE FROM THAT
ADDRESS.

1/7/2011 3
o SIX INTERRUPTS IN THE 8051
1) RESET : when the reset pin is activated , the 8051 jumps to the address
location 0000.this is the power up reset discussed in the chapter.
2) Two interrupts are set aside for the timers : one for timer 0 and one for
timer 1.memory locations 000BH and 001BHin the interrupt vector table
belong to timer 0 and timer 1, respectively.
3) Two interrupts are aside for hardware external hardware interrupts. Pin
numbers 12 and 13 in port 3 are for the external hardware interrupts
INT0 and INT1 respectively . these external interrupts are also referred
to as EX1 and EX2.memory locations 0003H and 0013H in the interrupt
vector table are assigned to INT0 and INT1 ,respectively.
4) Serial communication ahs a single interrupt that belongs to both receive
and transfer . the interrupt vector table location 0023H belongs to this
interrupt.

1/7/2011 4
oINTERRRUPT VECTOR
TABLE
Interrupt vector table for 8051

Interrupt ROM location(hex) pin


reset 0000 9
External hardware 0003 P3.2(12)
interrupt 0 (int0)
Timer 0 interrupts (TF0) 000B _
EXTERNAL hardware 0013 P2.3(13)
interrupt 1 (INT1)
Timer1 interrupt (TF1) 001B
Serial COM interrupt (R1 0023
and T1)

1/7/2011 5
o ENABLING AND DISABLING AN
INTERRUPT
 Steps in enabling an interrupt:
a) Bit D7 of the IE register must be set to high
to low the rest of register to take effect.
b) If EA=1, interrupts are enabled and will be
responded to if their corresponding bits in IE
are high. If EA=0, no interrupt will be
responded 0, even if the associated bit in
the IE register is high.

1/7/2011 6
INTERRUPT ENABLE REGISTER
EA _ ET2 ES ET1 EX1 ET0 ET1

 EA : disable all interrupts. If EA=0,no interrupt is


acknowledge . if EA=1,each interrupt source is individually
enabled or disabled by setting or clearing its enable bit.
_:not implemented , reserved for future use.
ET2:enables or disables timer 2 overflow or capture
interrupt (8952).
ES : enable or disable the serial port interrupt.
EXT1: enables or disables external interrupt 1.
EXT1: enable or disable external interrupt 1.
ET0: enable or disable timer 0 overflow interrupt.
EX0: : enables or disables external interrupt 0.
1/7/2011 7

You might also like