<< Chapter < Page | Chapter >> Page > |
We now provide an explanation of the shell C program
lab4main.c
listed in
Appendix A . The
lab4main.c
file contains the function
interrupt void irq
and a main program. The
main program is an infinite loop over blocks of
samples. Note that while the DSP is executing
instructions in this loop, interrupts occur every
BlockLen
samples. Inside the infinite loop,
you will insert code to do the operations whichfollow. Although each of these operations may be performed
in C or assembly, we suggest you follow the guidelinessuggested.
The function WaitAudio is an assembly function in the core code
which handles the CODEC interrupts. An interrupt from the CODEC
occurs every
BlockLen
samples. The
SetAudioInterrupt(irq)
call in the main program
tells the core code to jump to the
irq
function
when an interrupt occurs. In the
irq
function,
BlockLen
samples of the A/D input in
Rcvptr
(channel 1) are written to a length
inputs
buffer, and
BlockLen
of the output samples in the
outputs
buffer are written to the D/A output
via
Xmitptr
on channel 2. In C, pointers may be
used as array names so that
Xmitptr[0]
is the
first word pointed to by
Xmitptr
. As in the
assembly core, the input samples are not inconsecutive order. The right and left inputs are offset from
Rcvptr
respectively by
and
,
,,
.
The six output channels are accessed consecutively as offsetsfrom
Xmitptr
. On channel 1 of the
output, the input is echoed out.
You are to fill
the buffer
outputs
with the windowed
magnitude-squared FFT values by performing the operationslisted above.
In the main code, the
while(!input_full);
loop waits for
samples to collect in the
inputs
buffer. Next, the
inputs and outputs must be transferred. You are
to write this portion of code. This portion of code is tobe done first, within
BlockLen
sample times;
otherwise the first
BlockLen
of samples of
output would not be available on time. Once this loop isfinished, the lengthy processing of the FFT can continue.
During this processing, the DSP is interrupted every
BlockLen
samples to transfer samples. Once
this processing is over, the infinite loop returns to
while(!input_full);
to wait for
samples to finish collecting.
The flow diagram in summarizes the operation of the interrupt handling routine
As the list of operations indicates, bit-reversal and FFT
computation are to be done in both C and assembly. For theassembly version, make sure that the line defining
C_FFT
is commented in
lab4main.c
.
We are providing you with a shell assembly file, available at
v:\ece420\54x\dspclib\c_fft_given.asm
and shown
in
Appendix B , containing many
useful declarations and some code. The code for performingbit-reversal and other declarations needed for the FFT
routine are also provided in this section.
However, we would like you to enter this code
manually, as you will be expected to understand itsoperation.
Notification Switch
Would you like to follow the 'Ece 320 spring 2004' conversation and receive update notifications?