Rabbit 4000 Microprocessor
User's Manual
PREV INDEX NEXT


6. Interrupts

6.1 Overview

The Rabbit 4000 can operate at one of four priority levels, 0–3, with Priority 0 being the expected standard operating level. The current priority and up to three previous priority levels are kept in the processor's 8-bit IP register, where bits 0–1 contain the current priority. Every time an interrupt is handled or an IPSET instruction occurs, the value in the register is shifted left by two bits, and the new priority placed in bits 0–1. When an IPRES or IRET instruction occurs, the value in IP is shifted right by two bits (bits 0–1 are shifted into bits 6–7). On reset, the processor starts at Priority 3.

Most interrupts can be set to be Priority 1–3. A pending interrupt will be handled only if its interrupt priority is greater than the current processor priority. This means that even a Priority 3 interrupt can be blocked if the processor is currently at Priority 3. The System Mode Violation, Stack Limit Violation, Write Protection Violation, secondary watchdog, and breakpoint interrupts are always enabled at Priority 3. In addition, when the system/user mode is enabled and the processor is in the user mode, the processor will not actually enter Priority 3; any attempt to enter Priority 3 will actually be requested as Priority 2.

When an interrupt is handled, a call is executed to a fixed location in the interrupt vector tables; this operation requires 10 clocks, the minimum interrupt latency for the Rabbit 4000. There are two vector tables, the internal and the external interrupt vector tables, that can be located anywhere in logical memory by setting the processor's IIR and EIR registers. The IIR and EIR registers hold the upper byte of each table's address. For example, if IIR is loaded with 0xC4, then the internal interrupt vector table will start at the logical memory address 0xC400.

The internal interrupt vector table occupies 512 bytes, and the external interrupt vector table is 256 bytes in size. Since the RST and SYSCALL vectors use all eight bits of the IIR for addressing, the lowermost bit of IIR should always be set to zero so to keep some vectors from inadvertently overlapping.

Each interrupt's vector begins on a 16-byte boundary inside the vector tables. It may be possible to fit a small routine into that space, but it is typical to place a call to a separate routine in that location.

Some Rabbit 4000 instructions are "chained atomic," which means that an interrupt cannot occur between that instruction and the following instruction. These instructions are useful for doing things like exiting interrupt handlers properly or updating semaphores.

6.2 Operation

To ensure proper operation, all interrupt handler routines should be written according to the following guidelines.

6.3 Interrupt Tables

Table 6-1 shows the structure of the internal interrupt vector table. The first column is the vector address offset within the table. The second column shows the vectors in the first 256 bytes of the table, and the third column shows the vectors in the second 256 bytes.

Table 6-1. Internal Interrupt Vector Table Structure

Offset

0x0000+

0x0100+

0x00
Periodic Interrupt

0x10
Secondary Watchdog

0x20
RST 10

0x30
RST 18

0x40
RST20

0x50
RST 28

0x60
Syscall instruction

0x70
RST 38
PWM
0x80
Slave Port
Sys/User Mode Violation
0x90
Write Protect Violation
Quadrature Decoder
0xA0
Timer A
Input Capture
0xB0
Timer B
Stack Limit Violation
0xC0
Serial Port A
Serial Port E
0xD0
Serial Port B
Serial Port F
0xE0
Serial Port C
Network Port A
0xF0
Serial Port D
Timer C


Table 6-2 shows the structure of the external interrupt vector table. Each interrupt vector falls on a 16-byte boundary inside the table.

Table 6-2. External Interrupt Vector Table Structure

Offset

0x0000+

0x00
External Interrupt 0
0x10
External Interrupt 1
0x20

0x30

0x40
Breakpoints
0x50

0x60

0x70

0x80
DMA Channel 0
0x90
DMA Channel 1
0xA0
DMA Channel 2
0xB0
DMA Channel 3
0xC0
DMA Channel 4
0xD0
DMA Channel 5
0xE0
DMA Channel 6
0xF0
DMA Channel 7


There is a priority among interrupts if multiple requests are pending, as shown in Table 6-3. Interrupts marked as "cleared automatically" have their requests cleared when the interrupt is first handled.

Table 6-3. Interrupt Priorities 

Priority

Interrupt Source

Action Required to Clear the Interrupt

Highest
Breakpoint
Read the status from BDCR.

System Mode Violation
Cleared automatically.

Stack Limit Violation
Cleared automatically.

Write Protection Violation
Cleared automatically.

Secondary Watchdog
Restart secondary watchdog by writing to WDTCR.

External Interrupt 1
Cleared automatically.

External Interrupt 0
Cleared automatically.

Periodic Interrupt
Read the status from GCSR.

Quadrature Decoder
Read the status from QDCSR.

Timer B
Read the status from TBCSR.

Timer A
Read the status from TACSR.

Input Capture
Read the status from ICCSR.

PWM
Write any PWM register.

Timer C
Read the status from TCCSR.

Slave Port
Rd: Read from SPD0R, SPD1R or SPD2R.
Wr: Write to SPD0R, SPD1R, SPD2R or dummy write to SPSR.

DMA 7
Cleared automatically.

DMA 6
Cleared automatically.

DMA 5
Cleared automatically.

DMA 4
Cleared automatically.

DMA 3
Cleared automatically.

DMA 2
Cleared automatically.

DMA 1
Cleared automatically.

DMA 0
Cleared automatically.

Network Port A
Read interrupt status from NACSR

Serial Port E
Rx: Read from SEDR or SEAR.
Tx: Write to SEDR, SEAR, SELR or dummy write to SESR.

Serial Port F
Rx: Read from SFDR or SFAR.
Tx: Write to SFDR, SFAR, SFLR or dummy write to SFSR.

Serial Port A
Rx: Read from SADR or SAAR.
Tx: Write to SADR, SAAR, SALR or dummy write to SASR.

Serial Port B
Rx: Read from SBDR or SBAR.
Tx: Write to SBDR, SBAR, SBLR or dummy write to SBSR.

Serial Port C
Rx: Read from SCDR or SCAR.
Tx: Write to SCDR, SCAR, SCLR or dummy write to SCSR.
Lowest
Serial Port D
Rx: Read from SDDR or SDAR.
Tx: Write to SDDR, SDAR, SDLR or dummy write to SDSR.



Rabbit Semiconductor
www.rabbit.com
PREV INDEX NEXT