Professional Documents
Culture Documents
What is an interrupt?
What is an interrupt?
What is an interrupt?
Pete... Take the rubbish out Please...
What is an interrupt?
Ill do it later... Pete... Take the rubbish out Please...
What is an interrupt?
Ill do it later... Pete... Take the rubbish out Please...
Why?
All tasks are not created equal. Not all tasks are predictable.
Running
CPUS12
Tuesday, 7 July 2009
Stack
4
Running
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
4
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
5
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
5
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
5
Running
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
5
Running
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
5
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
5
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
6
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
6
Halted
CPUS12
Tuesday, 7 July 2009
Stack
6
Halted
CPUS12
Tuesday, 7 July 2009
Stack
6
Halted
CPUS12
Tuesday, 7 July 2009
Stack
6
Halted
CPUS12
Tuesday, 7 July 2009
Stack
6
Halted
CPUS12
Tuesday, 7 July 2009
Stack
6
Running
CPUS12
Tuesday, 7 July 2009
Stack
6
SCPU12 Interrupts
The MC9S12XDP512 contains vectored interrupts with hardware priority resolution that can be customized with software. The MC9S12XDP512 contains two external dedicated interrupt lines IRQ and XIRQ located on port E. The IRQ The XIRQ The MC9S12XDP512 contains numerous internal interrupt sources that are associated with the various internal subsystems.
A table of pointers in memory that point to subroutines that need to be executed once the interrupt it triggered. Each interrupt source has its own special location in this table.
Vector Address $FFFE $FFFC $FFFA Interrupt Source System reset Clock Monitor Reset COP Watchdog Reset Unimplemented OpCode SWI XIRQ IRQ CCR Mask None None None None None X-bit I-bit Local Enable None PLLCTL COP Rate select None None None IRQCR
9
Vector Base + $F8 Vector Base + $F6 Vector Base + $F4 Vector Base + $F2
Tuesday, 7 July 2009
IVBR ($0121)
VB7 VB6 VB5 VB4 VB3 VB2 VB1 VB0
10
What else?
Tuesday, 7 July 2009
The vector table makes the connection between a interrupt source and the corresponding code that must be executed. Code that is executed as a result of an interrupt is referred to as an interrupt service routine (ISR). By putting the address of the ISR into a particular position of the vector table, will ensure that the ISR will be executed if that interrupt source is triggered. So as long as the interrupt source is enabled, the ISR will run.
11
Controlling Interrupts
The X bit in the CCR is used to control the XIRQ interrupt source. The I bit in the CCR is used to control the remaining interrupt sources. The interrupts will only work if they have been properly enabled.
12
Controlling Interrupts
The Interrupt Process
Using the two bits in the CCR namely the X and I bits, it is possible to control the entire interrupt subsystem. Each maskable interrupt can be individually disabled or enabled by setting the appropriate bit in the devices control registers. During an interrupt, the X bit remains unchanged, this means a non maskable interrupt can occur within an interrupt service routine. The use of nested interrupts should be avoided, however it is possible to have nested interrupts if the I bit is cleared during an interrupt service routine (recommended only for experts). Interrupts are disabled on reset.
Tuesday, 7 July 2009 13
Before using interrupts, the interrupt vectors must be initialised to point to the appropriate interrupt service routines. If a subsystem uses the interrupt facility then the interrupt vector must be set and a interrupt service routine provided. The Hardware Reset interrupt vector must be set to point to the beginning of the code. When the processor is originally powered up or reset, the routine pointed to by the hardware interrupt service will be executed.
Tuesday, 7 July 2009 14
15
Interrupt Sources
Inside the MC9S12XDP512 there are approximately 128 possible subsystem interrupt sources that can be enabled or disabled by bits locally contained within the control registers of the particular I/O subsystem. Each of these sources has its own interrupt vector associated with it and therefore has space allocated inside the vector table. When an interrupt request is generated the value located in the interrupt vector for the particular source is fetched and loaded into the program counter.
16
Interrupt Sources
External Interrupt Sources (IRQ) An interrupt request on the IRQ pin is generated by external logic. The IRQ pin is an active low signal and you may set it to a level active or a negative edge response. The Interrupt Control Register located at $001E contains bits to select which response is needed and to enable or disable the IRQ pin.
IRQE: IRQ Select Edge Sensitivity (0=level triggered, 1=falling edge triggered). IRQEN: Enable IRQ pin (1=enabled, 0=GPIO)
17
18
CLOCK MONITOR FAILURE If the CPU clock signals slow down or fails and the Clock monitor is enabled. The clock monitor will detect a problem and issue a CME reset signal. However it is impossible for the CPU to execute the interrupt until the clock signal reappears.
19
COMPUTER OPERATING NORMALLY Also referred to as the watchdog timer. If your program crashes or hangs then this exception is triggered.
20
UNIMPLEMENTED OPCODE TRAP If for some reason the program gets lost and begins executing data, it is highly likely that it will try to execute an unimplemented op-code. If this does occur the CPU will trigger the an interrupt and the unimplemented opcode trap vector will be fetched and executed.
21
SOFTWARE INTERRUPT The software interrupt is effectively a branch to the subroutine whose address is located in the software interrupt vector. It is a software triggered interrupt.
22
NON-MASKABLE INTERRUPT REQUEST XIRQ is an external non-maskable interrupt input. It is controlled using only the X bit in the CCR. Once the X bit has been cleared it is impossible to set this bit again once the program has commenced.
23
Interrupts
There exists many internal interrupt sources form the various built-in subsystems. In order to use the interrupt capability of these subsystems, global interrupts must be enabled and the enable bit set in the appropriate control register for the I/O device. Some subsystems set a ag bit in a status register when an interrupt occurs and if this ag isnt reset then an interrupt will trigger again once ISR is complete.
24
Interrupt Subsystem
25
When an interrupt occurs the loop will be interrupted and will continue the loop when the ISR completes.
26
27
28
An interrupt service routine (ISR) is simply a subroutine terminated by an RTI instead of RTS.
The interrupt service routine is only executed once the interrupt vector has been initialised properly, interrupts have been enabled and unmasked, an interrupt has occurred, the CPU registers have been pushed onto the stack, and the vector has been fetched.
29
30
Do not worry about using registers in the ISR. Do not assume any register contents. Keep ISRs simple to begin with. Keep ISR short.
31
Another example
Virgin System
TCO:
Entry:
EQU
ORG
$FFEE ROMSTART ; Address of vector for Timer channel 0
LDS
#RAMEnd+1
;Location of TC0 interrupt vector ; The label of the address is the TCO ISR.
32
Another example
uBug12 System
TCO:
Entry:
EQU
ORG
$FFEE ROMSTART ; Address of vector for Timer channel 0
LDS
#RAMEnd+1
;Location of TC0 interrupt vector ; The label of the address is the TCO ISR.
33
Running
CPUS12
Tuesday, 7 July 2009
Stack
34
Running
CPUS12
Tuesday, 7 July 2009
Stack
34
Halted
CPUS12
Tuesday, 7 July 2009
Stack
34
Halted
CPUS12
Tuesday, 7 July 2009
Stack
34
Halted
CPUS12
Tuesday, 7 July 2009
Stack
34
Halted
CPUS12
Tuesday, 7 July 2009
Stack
34
Halted
CPUS12
Tuesday, 7 July 2009
Stack
34
Halted
CPUS12
Tuesday, 7 July 2009
Stack
34
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
34
CCR SP
CPUS12
Tuesday, 7 July 2009
CCR SP
CPUS12
Tuesday, 7 July 2009
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
36
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
36
Running
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
36
Running
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
36
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
36
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
37
Halted
CCR D X Y PC
CCR SP
CPUS12
Tuesday, 7 July 2009
Stack
37
Halted
CPUS12
Tuesday, 7 July 2009
Stack
37
Halted
CPUS12
Tuesday, 7 July 2009
Stack
37
Halted
CPUS12
Tuesday, 7 July 2009
Stack
37
Halted
CPUS12
Tuesday, 7 July 2009
Stack
37
Halted
CPUS12
Tuesday, 7 July 2009
Stack
37
Running
CPUS12
Tuesday, 7 July 2009
Stack
37