Professional Documents
Culture Documents
Unit IV 8051 - Interrupts
Unit IV 8051 - Interrupts
Software
Timer1 Flag Interrupt TF1
Serial Interrupt
Hardware
Timer Interrupts
X X X 1 0 0 0 0
Priority to Serial
Interrupt
IP register - Example
X X X 0 0 1 0 1
Note:
INT0 and INT1 has same priority. So, 8051 follows the default ranking
Which means INT0 has more priority than INT1
Interrupt Destination
When an INTERRUPT occurs, the program execution
point is transferred to the Interrupt Destination of that
particular interrupt
Interrupt Destination (cntd.,)
The Programmer has to make sure that the ISR of a
particular interrupt is present in the destination
address
A RETI instruction is used to return from the ISR.
Simultaneously, the RETI instruction resets interrupt
logic so that another interrupt can be serviced
TCON Register
Note:
Generating Interrupts by Software
When an Interrupt Flag is set to ‘1’ by any means, an
interrupt is generated unless blocked
Interrupt functions in 8051 C
void <interrrupt_name> (void) interrupt
<interrupt_number> using <register bank no.>
The using function attribute is used to select a register bank different from that of the
non-interrupt program code
The following rules apply to interrupt
functions:
No function arguments may be specified for an
interrupt function
The compiler generates an interrupt vector for each
interrupt function automatically
The Cx51 Compiler allows interrupt numbers within
the 0-31 range
‘Functions’ called from an ‘interrupt procedure’ must
function with the same register bank as the interrupt
procedure
Example
void falarm (void) interrupt 1 using 3
{
alarm_count = count + 2;
alarm = 1;
}
Fin
IE
IP
TCON