CE018 - Using the Fast Fourier Transform (FFT) for Frequency Detection
In this code example, we demonstrate how the DSP library functions can be used to perform an FFT on an input signal (vector).
About this Code Example
Microchip's 16-bit dsPICÂ® Digital Signal Controllers feature a DSP Engine in the CPU that is capable of executing a Fast Fourier Transform (FFT) with great efficiency (high speed and low RAM usage). The on-chip features enabling the FFT implementation include, bit-reversed addressing, Multiply-accumulate (MAC) type instructions and the ability to store and retrieve constants stored in Program memory.
Microchip provides a DSP functions library that provides in-place FFT functions.
In this code example, we demonstrate how the DSP library functions can be used to perform an FFT on an input signal (vector). The code example is reconfigurable to perfrom an FFT of any size, including common sizes of 64, 128, 256 and 512 points. The code example also allows the user to place the FFT coefficients (known as Twiddle Factors) in RAM or in Program Flash Memory. The project may be easily reconfigured by modifying the header file, FFT.h. By default, the example implements a 256-point FFT using coefficients stored in Program Flash memory.
The input signal for our example will be 256 points of a Square wave signal of frequency 1KHz sampled at 10 KHz. This signal was first generated by dsPICworks and then exported as an assembler file from dsPICworks. After exporting it out, the assembler file was modified to ensure the samples reside in Y-data space.
The FFT operation is performed on the input signal, in-place. This means that the output of the FFT resides in the same RAM locations where the input signal used to reside.
- Jul 22, 2011
First Upload to ECS