<< Chapter < Page Chapter >> Page >

Compile your project before looking at the resulting assembly file and investigating the differences between each block. Be sure to reference page 3-32 of the DSP Programmer's Guide to findout what the state of the FRCT and OVM bits are. Run this program on the DSP, halt the program, and compare theoutput values in a memory window. Does each block work properly for all possible values?

Compiling and linking

A working program can be produced by compiling the C code and linking assembly modules and the core module. The compilertranslates C code to a relocatable assembly form. The linker assigns physical addresses on the DSP to the relocatable dataand code segments, resolves .global references and links runtime libraries.

Close the mathex project and go back to the original Lab 4 project. In the future if there are additional source code files to include in the project, just follow the above instructions. Once you have completed lab4.c and c_fft_given.asm , select Project->Rebuild All . Load the output file onto the DSP as usual and confirm that valid FFTs are calculated. Once valid output is obtained, measure howmany clock cycles it takes to compute both the assembly and C FFT.

Quiz information

From your prelab experiments, you should be able to describe the effect of windowing and zero-padding on FFT spectralanalysis. In your DSP system, experiment with different inputs, changing N and the type of window. Can you explain what happens as the input frequency is increased beyond the Nyquist rate? Does the X k 2 coincide with what you expect from Matlab? What is the relationship between the observed spectrum and the DTFT?What would happen if the FFT calculation takes longer than it takes to fill inputs with N samples? How long does it take to compute each FFT? What are the tradeoffs between writing code in C versus assembly?

Appendix a:

lab4.c

#include "dsk5510_dual3006cfg.h" #include "dsk5510.h" #include "swi_process.h" #include "dsplib.h" #define N 1024 #define logN 10 #include "window.h" /* comment the next line to use DSPLIB fft */ //#define C_FFT #ifdef C_FFT /* Use C FFT */ /* function defined in lab4fft.c */ void fft(void); /* FFT data buffers */ int real[N]; /* Real part of data */ int imag[N]; /* Imaginary part of data */ #include "lab4fft.c" #else /* Use DSPLIB FFT */ /* Function defined by c_fft_given.asm */ void bit_rev(void); /* FFT data buffers (declared in c_fft_given.asm) */ extern int bit_rev_data[N*2]; /* Data output for bit-reverse function */ extern int fft_data[N*2]; /* In-place FFT & Output array */ #endif /* C_FFT */ // all data processing should be done in SWI_ProcessBuffer void SWI_ProcessBuffer() { static unsigned int mbox_value = 0; short *psrc, *pdest; unsigned int i; mbox_value |= SWI_getmbox(); // buffers are only processed when both transmit and receive are ready if((mbox_value & DMA_RECEIVE_DONE) && (mbox_value & DMA_TRANSMIT_DONE)) { mbox_value = 0; // get buffer pointers psrc = receive_buffer[receive_buffer_to_process_index]; pdest = transmit_buffer[transmit_buffer_to_fill_index]; // samples are interleaved in input buffer 3-4-1-2 // output buffer is organized 3-4-1-2-3-4-1-2 // The following code would copy input from each input channel to the // respective output channel: /* for (i = 0; i < 1024; i++) { pdest[4*i] = psrc[4*i]; //channel 3 output is channel 3 input pdest[4*i+1] = psrc[4*i+1]; //channel 4 output is channel 4 input pdest[4*i+2] = psrc[4*i+2]; //channel 1 output is channel 1 input pdest[4*i+3] = psrc[4*i+3]; //channel 2 output is channel 2 input } */ #ifdef C_FFT /* Use C FFT */ /* I n s e r t c o d e t o f i l l */ /* C F F T b u f f e r s */ #else /* Use DSPLIB FFT */ /* I n s e r t c o d e t o f i l l */ /* a s s e m b l y F F T b u f f e r s */ #endif /* C_FFT */ #ifdef C_FFT /* Use C FFT */ /* Multiply the input signal by the Hamming window. */ /* . . . i n s e r t C / a s m code . . . */ /* Bit-reverse and compute FFT in C */ fft(); /* Now, take absolute value squared of FFT */ /* . . . i n s e r t C / a s m code . . . */ /* Last, set the DC coefficient to -1 for a trigger pulse */ /* . . . i n s e r t C / a s m code . . . */ /* done, wait for next time around! */ #else /* Use DSPLIB FFT */ /* Multiply the input signal by the Hamming window. */ /* . . . i n s e r t C / a s m code . . . */ /* Compute FFT using DSPLIB function */ cfft((DATA *)fft_data,N, SCALE); /* Bit reverse using assembly function */ bit_rev(); /* Now, take absolute value squared of FFT */ /* . . . i n s e r t C / a s m code . . . */ /* Last, set the DC coefficient to -1 for a trigger pulse */ /* . . . i n s e r t C / a s m code . . . */ /* done, wait for next time around! */ #endif /* C_FFT */ receive_buffer_processed = 1; // flag receive buffer as processed transmit_buffer_filled = 1; // flag output buffer as full } }

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing laboratory (ece 420 55x). OpenStax CNX. Jan 18, 2010 Download for free at http://cnx.org/content/col10397/1.10
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing laboratory (ece 420 55x)' conversation and receive update notifications?

Ask