Microchip | The Embedded Control Solutions Company Register Login
Browse All
Microchip Technology
 369 Code Snippets

CE018 - Using the Fast Fourier Transform (FFT) for Frequency Detection

Microchip Technology

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.


Release History

  • Jul 22, 2011

    Version: 1.0.0

    First Upload to ECS

Download Contact the Developer

*Required Fields

  • Current Version:1.0.0
  • Created:Jul 22, 2011
  • Updated:Feb 26, 2015
  • Downloads:13694
  • MPLAB Version:latest
  • C Compiler:C30 v1.33 or above
  • Development Tools:dsPICDEMâ„¢ 1.1 Development Board dsPIC30F6014A DSC Plug-in module
  • Supported Devices:dsPIC30F

Corporate News


Stay Connected

Stay up to date with the latest news from Microchip Technology.