Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
46
Добавлен:
27.04.2015
Размер:
4.26 Mб
Скачать

Interrupts and the Processing States

 

 

 

 

Main

 

Interrupt

 

Program

 

 

Service Routine

 

 

 

Fetches

 

 

 

Fetches

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

II (NOP)

 

 

 

 

 

 

n6

 

 

 

 

 

 

No Fetch

 

 

 

I1

 

No Fetch

 

 

 

I2

 

 

 

 

 

I3

 

 

 

 

 

I4

 

 

 

 

 

I5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(a) Instruction Fetches from Memory

Illegal Instruction Interrupt

Recognized as Pending

Interrupt Control Cycle 1

 

 

 

 

 

 

 

i

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Interrupt Control Cycle 2

 

 

 

 

 

 

 

 

 

i

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Fetch

 

n1

n2

n3

n4

II

n6

 

ii1

ii2

ii3

ii4

 

ii5

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Decode

 

 

n1

n2

n3

n4

II

 

ii1

ii2

ii3

 

ii4

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Execute

 

 

 

n1

n2

n3

n4

NOP

 

ii1

ii2

 

ii3

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Instruction Cycle Count

1

2

3

4

5

6

7

8

 

9

10

11

12

13

 

14

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

i = Interrupt

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ii = Interrupt Instruction Word

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

II = Illegal Instruction

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

n = Normal Instruction Word

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(b) Program Controller Pipeline

 

 

 

 

 

AA0059

Figure 7-4. Illegal Instruction Interrupt Servicing

This interrupt can be used as a diagnostic tool to allow the programmer to examine the stack and locate the illegal instruction, or the application program can be restarted with the hope that the failure was a soft error. The ILLEGAL instruction, found in Appendix A, “Instruction Set Details,“ is useful for testing the illegal interrupt service routine to verify that it can recover correctly from an illegal instruction. Note that the illegal instruction trap does not fire for all invalid opcodes.

7.3.6 Interrupt Arbitration

Interrupt arbitration and control, which occurs concurrently with the fetch-decode-execute cycle, takes two instruction cycles. External interrupts are internally synchronized with the processor clock before their interrupt-pending flags are set. Each external and internal interrupt has its own flag. After each instruction is executed, the DSP arbitrates all interrupts. During arbitration, each pending interrupt’s IPL is compared with the interrupt mask in the SR, and the interrupt is either allowed or disallowed. The remaining pending

7-12

DSP56800 Family Manual

 

Exception Processing State

interrupts are prioritized according to the IPLs shown in Table 7-7, and the interrupt source with the highest priority is selected. The interrupt vector corresponding to that source is then placed on the program address bus so that the program controller can fetch the interrupt instruction.

Table 7-7. Fixed Priority Structure Within an IPL

Priority

 

 

 

 

Exception

Enabled By

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Level 1 (Non-maskable)

 

 

 

 

 

 

 

Highest

 

Hardware

RESET

 

 

 

 

 

 

 

Watchdog timer reset

 

 

 

 

 

 

Illegal instruction

 

 

 

 

 

 

HWS overflow

 

 

 

 

 

 

OnCE trap

 

 

 

 

Lower

 

SWI

 

 

 

 

 

 

 

 

 

 

 

 

Level 0 (Maskable)

 

 

 

 

 

 

Higher

 

IRQA

 

(external interrupt)

IPR bit 1

 

 

 

 

 

 

 

 

(external interrupt)

IPR bit 4

 

 

IRQB

 

 

 

 

 

 

Channel 6 peripheral interrupt

IPR bit 9

 

 

 

 

 

 

Channel 5 peripheral interrupt

IPR bit 10

 

 

 

 

 

 

Channel 4 peripheral interrupt

IPR bit 11

 

 

 

 

 

 

Channel 3 peripheral interrupt

IPR bit 12

 

 

 

 

 

 

Channel 2 peripheral interrupt

IPR bit 13

 

 

 

 

 

 

Channel 1 peripheral interrupt

IPR bit 14

 

 

 

Lowest

Channel 0 peripheral interrupt

IPR bit 15

 

 

 

 

 

 

 

 

Interrupts from a given source are not buffered. The processor will not arbitrate a new interrupt from the same source until after it fetches the second word of the interrupt vector of the current interrupt.

An internal interrupt-acknowledge signal clears the appropriate interrupt-pending flag for DSP core interrupts. Some peripheral interrupts may also be cleared by the internal interrupt-acknowledge signal, as defined in their specifications. Peripheral interrupt requests that need a read/write action to some register do not receive the internal interrupt-acknowledge signal, and their interrupt request will remain pending until their registers are read/written. Further, if the interrupt comes from an IRQ pin and is programmed as level triggered, the interrupt request will not be cleared. The acknowledge signal will be generated after the interrupt vectors have been generated, not before.

If more than one interrupt is pending when an instruction is executed, the processor will first service the interrupt with the highest priority level. When multiple interrupt requests with the same IPL are pending, a second fixed-priority structure within that IPL determines which interrupt the processor will service. For

Interrupts and the Processing States

7-13

Interrupts and the Processing States

two interrupts programmed at the same priority level (non-maskable or level 0), Table 7-7 shows the exception priorities within the same priority level. The information in this table only applies when two interrupts arrive simultaneously or where two interrupts are simultaneously pending.

Whenever a level 0 interrupt has been recognized and exception processing begins, the DSP56800 interrupt controller changes the interrupt mask bits in the program controller’s SR to allow only level 1 interrupts to be recognized. This prevents another level 0 interrupt from interrupting the interrupt service routine in progress. If an application requires that a level 0 interrupt can interrupt the current interrupt service routine, it is necessary to use one of the techniques discussed in Section 8.10.1, “Setting Interrupt Priorities in Software,” on page 8-30.

7.3.7 The Interrupt Pipeline

The interrupt controller generates an interrupt instruction fetch address, which points to the second instruction word of a two-word JSR instruction located in the interrupt vector table. This address is used instead of the PC for the next instruction fetch. While the interrupt instructions are being fetched, the PC is loaded with the address of the interrupt service routine contained within the JSR instruction. After the interrupt vector has been fetched, the PC is used for any subsequent instruction fetches and the interrupt is guaranteed to be executed.

Upon executing the JSR instruction fetched from the interrupt vector table, the processor enters the appropriate interrupt service routine and exits the exception processing state. The instructions of the interrupt service routine are executed in the normal processing state and the routine is terminated with an RTI instruction. The RTI instruction restores the PC to the program originally interrupted and the SR to its contents before the interrupt occurred. Then program execution resumes. Figure 7-5 shows the interrupt service routine. The interrupt service routine must be told to return to the main program by executing an RTI instruction.

The execution of an interrupt service routine always conforms to the following rules:

1.A JSR to the starting address of the interrupt service routine is located at the first of two interrupt vector addresses.

2.The interrupt mask bits of the SR are updated to mask level 0 interrupts.

3.The first instruction word of the next interrupt service (of higher IPL) will reach the decoder only after the decoding of at least four instructions following the decoding of the first instruction of the previous interrupt.

4.The interrupt service routine can be interrupted (that is, nested interrupts are supported).

5.The interrupt routine, which can be any length, should be terminated by an RTI, which restores the PC and SR from the stack.

7-14

DSP56800 Family Manual

 

Exception Processing State

Interrupt

Interrupt

Vector Table

Subroutine

Main

Program

Interrupt

 

 

 

 

 

Synchronized

 

 

JSR

 

ii2

 

 

 

 

 

 

 

 

 

Jump Address

 

 

and

 

 

 

ii3

 

 

 

 

 

 

 

 

 

 

 

 

Recognized

n1

 

 

 

 

 

 

 

ii4

as Pending

n2

 

 

 

 

 

 

 

 

 

 

 

Interrupt

Routine

Explicit

 

 

 

 

 

 

 

iin

Return From

 

 

 

 

RTI

Interrupt

 

 

 

(Should Be RTI)

 

 

(a) Instruction Fetches from Memory

Interrupt Synchronized and

Recognized as Pending

PC Resumes

Operation

Interrupts

Re-enabled

 

 

 

 

 

 

 

 

 

 

 

 

Interrupts Re-enabled

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Interrupt Control Cycle 1

i

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Interrupt Control Cycle 2

 

i

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Fetch

n1

n2

Adr

ii2

ii3

ii4

ii5

iin

RTI

— — —

 

n2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Decode

 

n1

JSR

JSR

JSR

JSR

ii2

ii3

ii4

ii5

iin

RTI

RTI

RTI

RTI

RTI

n2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Execute

 

 

n1

JSR

JSR

JSR

JSR

ii2

ii3

ii4

ii5

iin

RTI

RTI

RTI

RTI

RTI

n2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Instruction Cycle Count

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

i = Interrupt

ii = Interrupt Instruction Word n = Normal Instruction Word

(b) Program Controller Pipeline

AA0069

Figure 7-5. Interrupt Service Routine

Figure 7-5 demonstrates the interrupt pipeline. The point at which interrupts are re-enabled and subsequent interrupts are allowed is shown to illustrate the non-interruptible nature of the early instructions in the long interrupt service routine.

Reset is a special exception, which will normally contain only a JMP instruction at the exception start address.

There is only one case in which the stacked address will not point to the illegal instruction. If the illegal instruction follows an REP instruction (see Figure 7-6), the processor will effectively execute the illegal instruction as a repeated NOP, and the interrupt vector will then be inserted in the pipeline. The next instruction will be fetched, decoded, and executed normally.

Interrupts and the Processing States

7-15

Соседние файлы в папке DSP568xx