<< Chapter < Page Chapter >> Page >

Creating the window

As mentioned, you will be using the FFT to compute the spectrum of a windowed input. For your implementation youwill need to create a 1024-point Hamming window. First, create a Hamming window in matlab using the function hamming . Use the matlab function write_intvector_headerfile with name set to 'window' and elemperline set to 8 to create the header file that is included in lab4.c . The window has already been created for you.

Displaying the spectrum

Once the DFT has been computed, you must calculate the squared magnitude of the spectrum for display.

X k 2 X k 2 X k 2
You may find the assembly instructions sqrm and sqam useful in implementing .

Because the squared magnitude is always nonnegative, you can replace one of the magnitude values with a -1.0 as a triggerpulse for display on the oscilloscope. This is easily performed by replacing the DC term ( k 0 ) with a -1.0 when copying the magnitude values to the output buffer. Thetrigger pulse is necessary for the oscilloscope to lock to a specific point in the spectrum and keep the spectrum fixed on the scope.

Intrinsics

If you are planning on writing some of the code in C, then you may be forced to use intrinsics. Intrinsic instructionsprovide a way to use assembly instructions directly in C. An example of an intrinsic instruction is bit_rev_data[0]=_smpyr(bit_rev_data[0],window[0]) which performs the assembly signed multiply round instruction. You may also find the _lsmpy instruction useful. For more information on intrinsics, see page 3-29 of the TI-C55x DSP Programmer's Guide .

The following lines of code were borrowed from the C FFT to serve as an example of arithmetic operations in C. Save this code in a file called mathex.c and create a new project by going to Project->New... . In the following window, enter mathex as the name for the project and save it in its own folder on the W: drive. Verify that the Project Type is Executable (.out) and that the target is TMS320C55XX before clicking Finish.

int s1, s2; int t1, t2; int i1, i2; int n1 = 16383, n2 = 16382, n3 = 16381, n4 = 16380; void main(void) { /* Code for standard 32-bit hardware, */ /* with x,y limited to 16 bits */ s1 = (n1*n2 + n3*n4) >> 15; s2 = (n1 + n2) >> 1; /* Code for TI TMS320C55X series */ t1 = ((long int)(n1*n2) + (long int)(n3*n4)) >> 15; t2 = ((long int)n1 + (long int)n2) >> 1; /* Intrinsic code for TMS320C55X series */ i1 = _sadd(_smpy(n1,n2), _smpy(n3,n4)); i2 = _sshl(_sadd(n1, n2),-1); while(1); }

Add the mathex.c file to the project by left-clicking on the mathex.pjt file in the left-hand window and selecting Add Files to Project.. . By default, the generated assembly code is not saved. To save the generated assembly for later comparison, go to Project->Build Options . Under the Compiler tab, click on the Assembly category and make sure Keep Generated .asm Files is selected.

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