<< Chapter < Page Chapter >> Page >

C fft routine

A bit-reversing and FFT routine have also been provided in lab4fft.c , listed in Appendix C . Again, make sure you understand how the bit reversal is takingplace. In lab4main.c , the line defining C_FFT must not be commented for use of the C FFT routine. The sine tables (twiddle factors) are located in sinetables.h . This fft requires its inputs in two buffers, the real buffer real and the imaginary buffer imag , and the output is placed in the same buffers.The length of the FFT, N , and logN are defined in lab4.h , which is also listed in Appendix C . When experimenting with the C FFT make sure you modify these length values instead of the onesin the assembly code and lab4main.c !

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 . For the assembly FFT, use save_coef to save the window to a file that can then be included in your code with the .copy directive. For the C FFT, 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 lab4main.c .

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 squr and squra 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 6-22 of the TI-C54x Optimizing C/C++ Compiler User's Guide .

The following lines of code were borrowed from the C FFT to serve as an example of arithmetic operations in C. Savethis code in a file called mathex.c and compile this file. Look at the resulting assembly file and investigate the differences betweeneach block. Be sure to reference the compiler user's guide to find out what the state of the FRCT and OVM bits are. Does each blockwork properly for all possible values?

void main(void) { int s1, s2; int t1, t2; int i1, i2; int n1 = 16383, n2 = 16382, n3 = 16381, n4 = 16380; /* 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 TMSC5000 series */ t1 = ((long int)(n1*n2) + (long int)(n3*n4)) >> 15; t2 = ((long int)n1 + (long int)n2) >> 1; /* Intrinsic code for TMS320C54X series */ i1 = _sadd(_smpy(n1,n2), _smpy(n3,n4)); i2 = _sshl(_sadd(n1, n2),-1); }

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ece 320 spring 2004. OpenStax CNX. Aug 24, 2004 Download for free at http://cnx.org/content/col10225/1.12
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ece 320 spring 2004' conversation and receive update notifications?

Ask