Error debugging help

#define LIN_OUT 1   
#define FFT_N 256   
#define MERR 10     
#define PID_ON 1    
#define TRI_PERIOD 100 
#define F_BLACKMAN 0.02463994238109641755656975202572 
#include <math.h>   
#include <arm_common_tables.h>
#include <Adafruit_ZeroFFT.h>


// Photodiode array variables

byte CLKpin = 4;    
byte SIpin = 5;     
byte AOpin0 = A1;    
byte AOpin1 = A2;    

// Variables for determining the displacment from the FFT

int maxindex;      
float maxvalue;    
double kmax;        
float Am;          
float Bm;           
float theta;        
float preTheta = 0; 
int Nwrap = 0;      
float displacement; 
float predisplacement; 
int w = 0;
int prevw = 0;
int wdiff = 0;

// PID Variables

unsigned long lastTime;
double Output=0;  
double Setpoint;  
double kp = 0 / 1;    
double ki = 2/1;  
//double ki = 2/ 1;  
double kd = 0/ 100;    
double error;     
double preverror; 
float esum;       
float D;          
unsigned long time0 = 0; 
float MSerror = 0;  
float RMSerror = 0;
float elist[MERR];
int jerr = 0;        
float runningRMSerror = 0; t

float m = 0;      
float pchange = 0;
float lastp = 0;
float k = 1;
int p = 1;
float M = 0;
//int switchtime = 1200; 

void setup() {
  Serial.begin(9600);   
  INIT_PHOTO();         
  READ_PHOTO();        
  DO_FFT();                  
  FIND_PEAK_INDEX();  
  KMAX();             
  INIT_PHOTO();         
  READ_PHOTO();       
  PHASE_ANGLE();      
  DISPLACEMENT();     
  predisplacement = displacement; 
  Setpoint = 0;       
  delay(100);         
  START_EXPOSURE();   
}

void loop() {
  KMAX();                 
  READ_PHOTO();           
  PHASE_ANGLE();          
  WRAPPING();            
  DISPLACEMENT();        
  DO_FFT();                      
  FIND_PEAK_INDEX();       
  //OSC_SET();             
  PID_LOOP();                  
  //OSC_DAC();                 
  //TRI_DAC();             
  START_EXPOSURE();         
  SERIAL_PRINT();               
}

// Photodiode functions 

void ClockPulse() { // For sending clock pulses during reading of photodiode
  delayMicroseconds(1);
  digitalWrite(CLKpin, HIGH);
  digitalWrite(CLKpin, LOW);
}

void INIT_PHOTO() { // Intialization of photodiode
  
    pinMode(CLKpin, OUTPUT);
    pinMode(SIpin, OUTPUT);
  
 
    for ( int i = 0; i < 14; i++ )
    {
      digitalWrite(i, LOW);
    }
  // Clock out any existing SI pulse through the ccd register:
    for (int i = 0; i < 260; i++)
    {
      ClockPulse();
    }
  
    digitalWrite(SIpin, HIGH);
    ClockPulse();
    digitalWrite(SIpin, LOW);
    for (int i = 0; i < 260; i++)
    {
      ClockPulse();
    }
}

void READ_PHOTO() { // Read the photodiode
  
  
  digitalWrite(SIpin, HIGH);
  ClockPulse();
  digitalWrite(SIpin, LOW);

  
  for (int i = 0; i < 128; i++)
  {
    delayMicroseconds(20);  
    fft_input[2 * i] = analogRead(AOpin0);        
    fft_input[2 * i + 1] = 0;                     
    fft_input[2 * i + 256] = analogRead(AOpin1);  
    fft_input[2 * i + 257] = 0;                   
    ClockPulse();
  }

  
  digitalWrite(SIpin, HIGH);
  ClockPulse();
  digitalWrite(SIpin, LOW);

  
}

void START_EXPOSURE() { 
  
  for (int i = 0; i < 260; i++)
  {
    if (i == 18)
    {
          }
    ClockPulse();
  }
  
}

//Calculation Functions 

void DO_FFT() {  
  fft_reorder();  
  fft_run();      
  fft_mag_lin();   
}

void FIND_PEAK_INDEX() { 
  maxvalue = 0;
  maxindex = 0;
  for (int i = 5; i < 128; i++) 
  {
    if (fft_lin_out[i] > maxvalue) 
  
    {
      maxvalue = fft_lin_out[i]; // ...store the new max...
      maxindex = i;              // ...and the index at which it occurs.
    }
  }
}

void KMAX() { 
   
  kmax = 2 * PI / 256 * maxindex;
}

void PHASE_ANGLE() { 
  
  Am = 0;
  Bm = 0;
  for (int i = 0; i < 256; i++) // Calculate the real and imag Fourier components
  {
    Am = Am + float ((fft_input[2 * i]) * cos(kmax * i)); //magnitude of real part
    Bm = Bm + float ((fft_input[2 * i]) * sin(kmax * i)); //magnitude of imaginary part
  }
  theta = atan2(Bm, Am); // Complext phase angle (in radians)
}

void WRAPPING() { 
  if ((preTheta ) > (0.5 * PI) && (theta) < (-0.7 * PI)) {
    
    Nwrap = Nwrap + 1; // If so, add 1 to the number of wraps.
  }
  if ((preTheta) < (-0.7 * PI) && (theta) > (0.5 * PI)) {
    
    Nwrap = Nwrap - 1;     
  }
  preTheta = theta; 
}

void DISPLACEMENT() { 
  m =   2 * PI * Nwrap;

  displacement = ((-(theta + m) * 632) * (1 / (4 * PI)) * (1 / sqrt(2))) - predisplacement;
  
}

// Servo Functions

void PID_LOOP() { 
  error = Setpoint - displacement;

  // Store the current error signal; overwrite if necessary
  if( jerr >= MERR ){
    jerr = 0;
  }
  elist[jerr] = error;
  jerr++;

  // Calculate the running RMS error
  runningRMSerror = 0;
  for(int i=0; i<MERR; i++) {
    runningRMSerror += pow(elist[i],2);
  }
  runningRMSerror = sqrt(runningRMSerror/MERR);
  
  // Calculate the mean-squared and root-mean-square errors over all time
  MSerror = (k - 1) / k * MSerror + pow(error, 2) / k; 
  RMSerror = sqrt(MSerror);
  k = k + 1;

  // Integral of error over all time
  esum = esum + error;
  
  // Derivative of error
  time0 = millis();
  D = (error - preverror) / (time0 - lastTime);
  
  // The feedback signal (in millivolts)
  // The minus signs are to make sure the piezo moves in the right direction
  Output = -(kp * error) -(ki * esum) -(kd * D);

  // Send the feedback to the DAC if PID_ON is 1
  /*if (PID_ON) {
    val = offset + Output;
    val = max(val, 0);    
    val = min(val, 4096);
    DAC_TRANSFER();
  }

  // Save the current time and error for calc'ing the derivative next cycle
  lastTime = time0;
  preverror = error;*/
}

void SERIAL_PRINT(){
  
  Serial.print(displacement);
  Serial.print(" , ");
  Serial.println(millis());
  Serial.print(" ") ; 
}

I got the error below when i try to compile this code for the Arduino Zero. Why am I getting this error?

In file included from /Users/RAJU/Library/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/arm_common_tables.h:44:0,
from /Users/RAJU/Documents/Documents/All Folders/Arduino 2017_v03_Maintable/Arduino-zero/DIS_SET_V04_Arduino-zero/DIS_SET_V04_Arduino-zero.ino:11:
/Users/RAJU/Library/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/arm_math.h:314:4: error: #error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"
#error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0"

^
exit status 1
Error compiling for board Arduino/Genuino Zero (Programming Port).

There is a file named arm_common_tables.h in the Adafruit FFT library but if you look at the error message:

In file included from /Users/RAJU/Library/Arduino15/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include/arm_common_tables.h:44:0

you can see that is not the file being used. The way to get the Adafruit FFT library's file to be included instead of the CMSIS one is to change the order of your #include directives:

#include <Adafruit_ZeroFFT.h>
#include <arm_common_tables.h>

If for some reason you did want to use the CMSIS file instead you can solve the error by adding this #define before including that file:

#define ARM_MATH_CM0PLUS

but I'm guessing the first solution is the correct one in this case.

After that is resolved you will encounter some other errors in your code.

I have changed as you suggested . The following is the order but its still throwing out the errors.

#define LIN_OUT 1 // Include the resources for the linear output function
#define Adafruit_ZeroFFT_N 2048 // Sets the ZeroFFT length to 5096 points
#define MERR 10 // Number of error values to store in elist[MERR]
#define PID_ON 1 // Use PID feedback or not
#define TRI_PERIOD 100 // Half-period of triangle wave in loops
#define F_BLACKMAN 0.02463994238109641755656975202572 // Osillation freq. for Blackman filter
#define ARM_MATH_CM0PLUS
#include <Adafruit_ZeroFFT.h>
#include <arm_common_tables.h>
#include <arm_math.h>

I'm guessing it's throwing out new errors caused by other problems in your code, which I already told you it would do.

When you encounter an error you'll see a button on the right side of the orange bar "Copy error messages". Click that button. Paste the error in a message here USING CODE TAGS (</> button on the toolbar).