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

Software Techniques

 

MOVE

#$1234,R3

; Contents of this register not

 

 

; required in tight loop

MOVE

#$5aa,A

; Contents of this register not

 

 

; required in tight loop

PUSH

R3

; Prepare for tight loop: X0, Y0 are

 

 

; unused and available, and R0 already

PUSH

A0

; points to that required for loop

 

PUSH

A1

 

PUSH

A2

 

; Enter Section with Tight Loop - R3 and A can now be used by tight loop

MOVE

$C000,R3

 

 

CLR

A

 

 

MOVE

 

X:(R0)+,Y0

X:(R3)+,X0

REP

#32

 

 

MAC

X0,Y0,A

X:(R0)+,Y0

X:(R3)+,X0

MOVE

A,X:(R2)+

; store result

POP

A2

; tight loop completed, restore

POP

A1

; borrowed registers

 

 

POP

A0

 

 

POP

R3

 

 

In the preceding example there are four PUSH instruction macros in a row. For more efficient and compact code, use the technique outlined in Section 8.5, “Multiple Value Pushes.” In certain cases it may also be possible to store critical information within the first 64 locations of X data memory, on the top of the stack, or in an unused register such as N when an extra location is required within a tight loop itself.

8.10 Interrupts

The interrupt mechanism on the DSP56800 is simple, yet flexible. There are two levels of interrupts: maskable and non-maskable. All maskable interrupts on the chip can be masked at one spot in the SR. Likewise, individual peripherals can be individually masked within one register, within the interrupt priority register (IPR), or at the peripheral itself. It is beneficial to have a single register in which all maskable interrupts can be individually masked. This gives the user the capability to set up interrupt priorities within software.

When programming interrupts, it is necessary to correctly set up the following tasks:

1.Initialize and program the peripheral, enabling interrupts within the peripheral.

2.Program the IPR to enable interrupts on that particular interrupt channel.

3.Enable interrupts in the SR.

8.10.1 Setting Interrupt Priorities in Software

This section demonstrates several different styles of coding possible for ISRs on the DSP56800 core. In counting the number of overhead instruction cycles, it is important to remember that the JSR instruction executes in four instruction cycles when entering an interrupt, and that the RTI instruction now takes five instruction cycles to complete.

8-30

DSP56800 Family Manual

 

Interrupts

8.10.1.1 High Priority or a Small Number of Instructions

During ISRs that are short, it is recommended that level 0 interrupts remain disabled. Since the routines are short, it is not nearly so important to interrupt them, because they are guaranteed to complete execution quickly. This is also recommended for ISRs with a very high priority, which should not be interrupted by some other source.

;Interrupt Service Routine

;DSP56800 core (Interrupts Remain Masked, 9 Overhead Cycles)

JSR

ISR

;

located in interrupt vector table

ISR

 

;

Long ISR

;(interrupt code) RTI

8.10.1.2 Many Instructions of Equal Priority

For ISRs that require a significant number of instruction cycles to complete, it is possible to reduce the interrupt servicing overhead if all interrupts can be considered to have the same priority. This is shown in the following generic ISR.

;Interrupt Service Routine for Long Interrupt

;DSP56800 core (Interrupts Remain Masked, 11 Overhead Cycles)

JSR

ISR

; located in interrupt vector table

ISR

 

; Long ISR

BFCLR

#$0200,SR; re-enable interrupts with new mask

;(interrupt code) RTI

 

Software Techniques

8-31

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