Sie sind auf Seite 1von 15

Interrupt

Sistem Mikroprosesor ELS3202

Week 7 Session 1
Introduction
• Instructions that executed by microcontroller
stored in program memory
• By default, CPU will execute the instructions
from 0x0000 address and increases by one bit.
So 0x0000 and then 0x0001.
Instruction is addressed by the program counter.
• If there is program jump (branching, subroutine
call, or loop), the program will jump out from the
recent address to the jumping address.
Interrupt definition
• An interrupt is an exception, a change of
the normal progression, or interruption in
the normal flow of program execution.
• An interrupt is essentially a hardware
generated function call.
• Interrupts are caused by both internal and
external sources.
Interrupt definition
• An interrupt causes the normal program
execution to halt and for the interrupt
service routine (ISR) to be executed.
• At the conclusion of the ISR, normal
program execution is resumed at the point
where it was last.
Interrupt

Instruction 2

Instruction 1 Main Loop Instruction 3


Program

Instruction n

3. Back to main 2. Jump to


program interrupt 1. Interrupt

Interrupt trigger
Interrupt routine

Interrupt routine
executed
Interrupt
Interrupt Vector

• In interrupt, program memory address is


the first location of program jump
• Interrupt vector is unique and specific for
every interrupt.
• Therefore, each interrupt has its own
interrupt vector
Interrupt trigger
• Internal interrupts or software interrupts
Triggered by a software instruction and operate
similarly to a jump or branch instruction
• External interrupts or hardware interrupts
Caused by an external hardware module
Reset and Interrupt Vectors
Reset and Interrupt Vectors

• All interrupts have separate interrupt


vectors in the interrupt vector table
• Interrupts have priority in accordance with
their position in the table.
• Lower interrupt vector address have
higher priority.
• Reset has top priority.
Interrupt initialization

• In initialization program, the program


should enable the interrupt
• Initialization consist of:
– Enable the interrupt triggered
– Enable global interrupt
Interrupt routine
• Continuously executed if interrupt is triggered.
• This routine can be located at the address of
interrupt vector or another address
• At interrupt vector address, commonly using the
instruction jump to interrupt routine
• A routine muse end with RETI (return from
interrupt)
External interrupt
• Atmega8535 has 3 external interrupt
triggered.
INT0(PD2),INT1(PD3),INT2(PB2)
• External interrupt can be executed using
register MCUCR. ( Detail in datasheet
page 68)
External interrupt enable register

• Bit 1, 0 – ISC01, ISC00: Interrupt Sense Control 0 Bit 1 and Bit 0


External interrupt enable register
• One bit register should be set to enable external
interrupt
• The bit is located at register GICR (General
Interrupt Control Register)
• Bits that effected by the interrupt located at
register GIFR (General Interrupt Flag Register)
(p.70)

Das könnte Ihnen auch gefallen