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

Cooley-Tukey FFT for 16-bit Integer Numbers

Microchip Technology

This library allows calculating FFT for the signals entered as an array of 16-bit signed integer numbers. The DSP CPU instructions are not used and the code will work for any 16-bit PIC device from PIC24F to dsPIC33E. The result of the calculation is written to the same array used for the input data. The calculation algorithm is based on Cooley-Tukey FFT algorithm with decimation in frequency. The permutation is performed on the final result to order harmonics. The twiddle coefficients for the transform and result permutation tables are stored in flash (PSV .const section). The valid FFT sizes are 8, 16, 32, 64, 128, 256, 512, 1024 and 2048. The size of the variables in the array is limited by 16-bits for real and imaginary parts. To avoid the overflows and fit into 16-bits, before each iteration (radix 2 butterflies), the results are shifted one bit right (rounded).  Though the rounding decreases the result precision and adds a noise to the FFT result the use of just 16-bit numbers makes the FFT calculations fast.  For PIC24F @ 16MIPS (32 MHz oscillator frequency), the time required for the calculation is

60 uS (8 points),
160 uS (16 points),
400 uS (32 points),
950 uS (64 points),
2 mS (128 points),
4.6 mS (256 points),
10 mS (512 points),
22 mS (1024 points).
The quality of the conversion can be good for many applications such as audio signal spectrum indicators, DTFM signals decoding, signal frequency estimation, signal quality estimation and so on. The harmonics are presented as complex numbers with real and imaginary parts. To calculate the harmonics amplitudes and phases the special functions are provided.

About this Code Example

Please read "FFT_Help.pdf" help file located in "FFT Code" folder for more information.


Release History

  • Apr 9, 2015

    Version: 1.0.0

    Initial Release

Download Contact the Developer

*Required Fields

  • Current Version:1.0.0
  • Created:Apr 9, 2015
  • Updated:May 16, 2017
  • Downloads:16273
  • MPLAB Version:Any
  • C Compiler:xc16
  • Development Tools:MPLABX, xc16 compiler
  • Supported Devices:from PIC24F to dsPIC33E

Corporate News


Stay Connected

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