FFT for LPC1114FN28 with UTI_FFT_Real_mod
Dependencies: UIT_FFT_Real_mod mbed
Fork of Demo_FFT_IFFT by
main.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2014-12-19
- Revision:
- 1:f070e455cea0
- Parent:
- 0:5bed9d6dc43b
- Child:
- 2:18b19edf441d
File content as of revision 1:f070e455cea0:
//-------------------------------------------------------------- // Demo program of FftReal class // Copyright (c) 2014 MIKAMI, Naoki, 2014/12/19 //-------------------------------------------------------------- #include "dftComplex.hpp" #include "fftReal.hpp" #include "mbed.h" using namespace Mikami; int main() { const int N = 256;//16; // number of date for FFT float x1[N], x2[N]; Complex y1[N], y2[N/2+1]; // Generate random data srand(1234); for (int n=0; n<N; n++) x1[n] = 2.0f*rand()/(float)RAND_MAX - 1.0f; printf("\r\n#### Original data for DFT ####\r\n"); for (int n=0; n<N; n++) printf("f[%2d]: %8.4f\r\n", n, x1[n]); // DFT, for comarison DftComplex(x1, y1, N); printf("\r\n#### Result of direct DFT ####\r\n"); printf(" real imaginary\r\n"); for (int n=0; n<N; n++) printf("F[%2d]: %8.4f, %8.4f\r\n", n, y1[n].real(), y1[n].imag()); Timer tm; // for measurement of execution time // FFT FftReal fft(N); tm.reset(); tm.start(); fft.Execute(x1, y2); tm.stop(); printf("\r\nExecution time (FFT): %d [us]\r\n", tm.read_us()); printf("\r\n#### Result of DFT using FFT ####\r\n"); for (int n=0; n<=N/2; n++) printf("F[%2d]: %8.4f, %8.4f\r\n", n, y2[n].real(), y2[n].imag()); // IFFT tm.reset(); tm.start(); fft.ExecuteIfft(y2, x2); tm.stop(); printf("\r\nExecution time (IFFT): %d [us]\r\n", tm.read_us()); printf("\r\n#### Result of IFFT ####\r\n"); printf(" original IFFT of FFT\r\n"); for (int n=0; n<N; n++) printf("f[%2d]: %8.4f, %8.4f\r\n", n, x1[n], x2[n]); }