Hello to all , I am pretty new to this subject so please bare with me ..I am just trying to do a basic FFT calculation code using the Code Composer Studio (CCS v5) my goal is to see the number of clock cycles to compute a Radix-2 FFT; the input is a 256 points sine wave, now if i try to see the FFT magnitude which is supposed to be a dirac impulse, the plot comes out to be random..i'll put my code in here, maybe i'm missing something; Can anyone help me Please..! #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <dsp_radix2.h> #include <dsp_fltoq15.h> #define PI (3.141592654) #define N (256) float x[N]; short y[N]; int gen_twiddle(short *w, int n, double scale) { double angle, step; int i; step = (2.0 * PI) / (double)n; for (i = 0, angle = 0.0; i < n; i += 2, angle += step) { w[i + 0] = d2s(scale * -cos(angle)); w[i + 1] = d2s(scale * -sin(angle)); } return n; } int main(void) { int i, size; double scale = 32767.5; short *w; for(i=1; i<N; i++) { x[i] = sin(2 * PI *10 * i/N); } DSP_fltoq15(x,y,N); //float to Q15 format. /*========================================================= */ /*Generate the twiddle-factor array*/ /*=========================================================== */ size = gen_twiddle(w, N, scale); printf("const short w[2 * %d] =n{", size / 2); for (i = 0; i < size; i++) { printf("%s%c0x%.4X", i == 0 ? "n " : (i & 7) == 0 ? ",n " : ", ", w[i] < 0 ? '-' : ' ', abs(w[i])); } printf("n};n"); /*========================================================= */ /*Perform the Radix 2 FFT routine using the function predifined in the DSP library*/ /*=========================================================== */ DSP_radix2(N, y, w); } --------------------------------------- Posted through http://www.DSPRelated.com
FFT calculation problem using TMS320C6416
Started by ●April 9, 2015