Compiler error

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Tomper
Posts: 19
Joined: 30 Aug 2008 02:15

Compiler error

#1 Post by Tomper » 31 Oct 2008 14:07

Hi

I have this code for a recursive FFT/IFFT algorithm, the thing is this code compiles fine under Borland C++ compiler but when I try to port it to MikroC it gives me a bunch of internal error messages. When I click the error it takes me to the fft_rec(N ,0, 1, x, X, XX) function call, I dont know if this is because of the recursive nature of the program, but I saw in the manual that recursive functions are allowed...I really need this desperatlely to work, please help...





[#define TWO_PI (6.2831853071795864769252867665590057683943L)

/* function prototypes */
void fft1(int N, double x[64][2], double X[64][2]) ;
void fft_rec(int N, int offset, int delta, double x[64][2], double X[64][2], double XX[64][2]) ;
void ifft(int N, double x[64][2], double X[64][2]) ;

/* FFT */
void fft1(int N, double x[64][2], double X[64][2])
{
/* Declare a pointer to scratch space. */
double XX[64][2];

/* Calculate FFT by a recursion. */
fft_rec(N ,0, 1, x, X, XX);


}

/* FFT recursion */
void fft_rec(int N, int offset, int delta,
double x[64][2], double X[64][2], double XX[64][2])
{

int N2 = N/2; /* half the number of points in FFT */
int k; /* generic index */
double cs, sn; /* cosine and sine */
int k00, k01, k10, k11; /* indices for butterflies */
double tmp0, tmp1; /* temporary storage */

if(N != 2) /* Perform recursive step. */
{
/* Calculate two (N/2)-point DFT's. */
fft_rec(N2, offset, 2*delta, x, XX, X);
fft_rec(N2, offset+delta, 2*delta, x, XX, X);

/* Combine the two (N/2)-point DFT's into one N-point DFT. */
for(k=0; k<N2; k++)
{
k00 = offset + k*delta; k01 = k00 + N2*delta;
k10 = offset + 2*k*delta; k11 = k10 + delta;
cs = cos(TWO_PI*k/N); sn = sin(TWO_PI*k/N);
tmp0 = cs * XX[k11][0] + sn * XX[k11][1];
tmp1 = cs * XX[k11][1] - sn * XX[k11][0];
X[k01][0] = XX[k10][0] - tmp0;
X[k01][1] = XX[k10][1] - tmp1;
X[k00][0] = XX[k10][0] + tmp0;
X[k00][1] = XX[k10][1] + tmp1;
}
}
else /* Perform 2-point DFT. */
{
k00 = offset; k01 = k00 + delta;
X[k01][0] = x[k00][0] - x[k01][0];
X[k01][1] = x[k00][1] - x[k01][1];
X[k00][0] = x[k00][0] + x[k01][0];
X[k00][1] = x[k00][1] + x[k01][1];
}
}

/* IFFT */
void ifft(int N, double x[64][2], double X[64][2])
{
int N2 = N/2; /* half the number of points in IFFT */
int i; /* generic index */
double tmp0, tmp1; /* temporary storage */

/* Calculate IFFT via reciprocity property of DFT. */
fft1(N, X, x);
x[0][0] = x[0][0]/N; x[0][1] = x[0][1]/N;
x[N2][0] = x[N2][0]/N; x[N2][1] = x[N2][1]/N;
for(i=1; i<N2; i++)
{
tmp0 = x[0]/N; tmp1 = x[1]/N;
x[0] = x[N-i][0]/N; x[1] = x[N-i][1]/N;
x[N-i][0] = tmp0; x[N-i][1] = tmp1;
}
}


]

Tomper
Posts: 19
Joined: 30 Aug 2008 02:15

#2 Post by Tomper » 31 Oct 2008 14:14

Hi I would just like to add that I am using a dsPIC 30F4013@120Mhz with 1MB of RAM. This code is also not the whole code, this is just the FFt algorithm's code, the other code works fine, its when I want to add these functions that the troubles start

idakota
Posts: 334
Joined: 27 Sep 2006 08:07
Location: Pretoria/South Africa
Contact:

#3 Post by idakota » 01 Nov 2008 07:50

Do you only get an "Internal Error"? Try scrolling up the message view, sometimes the real error message gets hidden further up.

Also, are you sure your dsPIC has 1MB of RAM? The largest dsPIC30 I could find has 8 kB and the dsPIC 30F4013 has 2 kB of RAM...

Tomper
Posts: 19
Joined: 30 Aug 2008 02:15

#4 Post by Tomper » 02 Nov 2008 20:41

yes the internal error is the only error message I get and a suspicious pointer conversion warning..you are right about the 2kB of RAM

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”