Motorola DSP56305 Manuel d'utilisateur Page 31

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 112
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 30
3-2 Optimizing DSP56300/DSP56600 Applications MOTOROLA
Program Control
Hardware Loops
A common programming technique is known as “loop unrolling”,
in which a high-level loop is replaced by the inner loop code,
repeated N times, thus saving the time needed to decrement the
counter, test for the end of the loop, and jumping back to the top.
From the above explanation, it follows that this technique is less
efficient in the DSP56300/DSP56600 family—the hardware executes
loops normally at the same speed as unrolled code (except for the
initializing DO instruction itself, which takes 5 cycles). Loops
should be unrolled only when the 5-cycle initialization is
meaningful in comparison to the total loop length, especially if this
loop is nested in another loop and the 5-cycle delay is multiplied.
See the example in Section 7.1.1 on page 7-1.
High-level “for” loops are normally implemented in assembly with
the DO instruction. The instructions DO FOREVER and BRKcc
(break on condition) may be used to implement high-level “while
or “repeat” loops efficiently. The following example is a wave
generator that sends data to a peripheral (Host Interface HI08 in this
example) until a hardware interrupt (IRQA
) sets a flag, signalling
the end of the loop. The core drives the HI08 transmitter by polling
the HTDE (Host Transmitter Data Empty) bit in the HI08 status
register. The C high-level code may look like:
while (!flag){
a1 = next_wave_value();
wait_until_transmitter_empty();
send_data(a1);
}
and in Assembler:
org p:I_IRQA ;IRQA_ interrupt vector
bset #0,x:<FLAG ;occupies 2 words
org p:MAIN_PROGRAM
...
move #0,x0
move x0,x:FLAG ;clear FLAG register
bclr #0,sr ;clear carry bit
do forever,_END_LOOP
brkcs ;break loop if carry bit set
jsr NEXT_WAVE_VALUE;new value returned in a1
_WAIT
jclr #0,x:M_SSR,_WAIT;wait until transmitter empty
btst #0,x:FLAG ;set carry by flag value
movep a1,x:M_HTX ;transmit data to host.
_END_LOOP
Vue de la page 30
1 2 ... 26 27 28 29 30 31 32 33 34 35 36 ... 111 112

Commentaires sur ces manuels

Pas de commentaire