Hi!
Thanks to your previous help, I have fixed my linker file and all memory arrangement, and simple programs run flawlessly in my CLA.
But then I get to running an FFT code I've written, and thr problems begin. The code runs fine on the main core (tested the correctness via MATLAB).
When I transferred the code to CLA first time, it just didn't execute at all, showing no errors during building or debugging. Then I split the FFT into several smaller sub-functions, and the code miraculously started executing, but the output was just ve-e-ery slightry relevant to what should be, an in terms of dsp such small accuracy is unacceptable.
Here are my FFT tries: the united one and a split one. The CLA code is triggered from the main function by Cla1ForceTask1andWait();
#include "fft_test1_cla.h"
#include "F28x_Project.h"
//FFT variables:
int16_t n, nspan, submatrix, node;
int16_t N1;// = 8;//1<<logN;
double temp, angle, realtwiddle, imtwiddle;
int16_t span;
int16_t i;
//Rev bits variables:
int16_t forward, rev, toggle;
int16_t nodd, noddrev; // to hold bitwise negated or odd values
int16_t halfn, quartn, nmin1;
void innerloop();
void secondloop();
void outerloop();
void addandsub();
void rotations();
void reverse (double *real, double *output);
__interrupt void Cla1Task1 ( void )
{
N1=8;
span=8;
n=0;
outerloop();
}
void innerloop()
{
addandsub();
rotations();
}
void addandsub()
{
nspan = n+span;
temp = real[n] + real[nspan]; // additions & subtractions
real[nspan] = real[n]-real[nspan];
real[n] = temp;
temp = im[n] + im[nspan];
im[nspan] = im[n] - im[nspan];
im[n] = temp;
}
void rotations()
{
angle = primitive_root * node; // rotations
realtwiddle = CLAcos(angle);
imtwiddle = -CLAsin(angle);
temp = realtwiddle * real[nspan] - imtwiddle * im[nspan];
im[nspan] = realtwiddle * im[nspan] + imtwiddle * real[nspan];
real[nspan] = temp;
n++;
}
void secondloop()
{
for(submatrix=0; submatrix<(N1>>1)/span; submatrix++)
{
for(node=0; node<span; node++){
innerloop();
}
}
}
void outerloop()
{
for(span=N1>>1; span; span>>=1) // loop over the FFT stages
{
primitive_root = -(3.14159265359/span);
secondloop();
}
}
__interrupt void Cla1Task1 ( void )
{
N1=8;
span=8;
n=0;
for(span=N1>>1; span; span>>=1) // loop over the FFT stages
{
primitive_root = -(3.14159265359/span); // define MINPI in the header
//secondloop();
//__mdebugstop();
//#pragma MUST_ITERATE(loop2)
for(submatrix=0; submatrix<(N1>>1)/span; submatrix++)
{
// __mdebugstop();
//#pragma MUST_ITERATE(loop3)
for(node=0; node<span; node++)
{
__mdebugstop();
nspan = n+span;
temp = real[n] + real[nspan]; // additions & subtractions
real[nspan] = real[n]-real[nspan];
real[n] = temp;
temp = im[n] + im[nspan];
im[nspan] = im[n] - im[nspan];
im[n] = temp;
angle = primitive_root * node; // rotations
realtwiddle = CLAcos(angle);
imtwiddle = -CLAsin(angle);
temp = realtwiddle * real[nspan] - imtwiddle * im[nspan];
im[nspan] = realtwiddle * im[nspan] + imtwiddle * real[nspan];
real[nspan] = temp;
n++; // not forget to increment n
} // end of loop over nodes
__mdebugstop();
n = (n+span) & (N1-1); // jump over the odd blocks
} // end of loop over submatrices
} // end of loop over FFT stages
__mdebugstop();
//reverse(real,outputR);
//reverse(im, outputI);
}
