Elektronikprojekt Grupp 13 / Mbed OS test_fft_grp13

Dependencies:   mbed-dsp

Fork of mbed-os-example-blinky by Elektronikprojekt Grupp 13

Revision:
52:d5c59769e1de
Parent:
51:837137ab83ed
Child:
53:3187ccbe0cca
--- a/main.cpp	Wed Apr 05 14:06:32 2017 +0000
+++ b/main.cpp	Wed Apr 05 15:11:42 2017 +0000
@@ -53,13 +53,39 @@
     complex c3 = c1 + c2;
     pc.printf("hello \n");
  
+ 
+ 
  //...Inside your signal processing function
    //   Allocate memory for signal data
-   complex *pSignal = new complex[1024];
+   complex *pSignal_1 = new complex[1024];
+   complex *pSignal_2 = new complex[1024];
    //...Fill signal array with data
    //   Apply FFT
-   CFFT::Forward(pSignal, 1024);
+   CFFT::Forward(pSignal_1, 1024);
+    CFFT::Forward(pSignal_2, 1024);
+ 
    //...Utilize transform result
+   complex *corrSignal = new complex[1024];
+   startCorr = corrSignal;
+   for( i=0; i<1024; i++){
+       *corrSignal = (*pSignal_1) * (*pSignal_2);
+       corrSignal++;
+       pSignal_1++;
+       pSignal_2++;
+   }
+   
+   int counter = 0;
+   int maxPos = 0; //delay i form av antal sample
+   complex maxValue = (0,0);
+   for(i=0; i<1024; i++){
+       if (*corrSignal > abs(maxValue) ){
+            maxValue = *corrSignal;
+            maxPos = counter;    
+       }     
+       counter++;
+       corrSignal++;      
+    }
+       
    //   Free memory
    delete[] pSignal;