hi,
i am trying to execute a code w.r.t speech recognition on tms320c6713 kit in
ccsv3.1 . the following code is a part of it.
#define FS 10000
#define PTS 256
#define PI 3.14159265358979
#pragma DATA_SECTION(x,".SDRAM$heap")
#pragma DATA_SECTION(spec,".temp")
#pragma DATA_SECTION(nx1,".SDRAM$heap")
#pragma DATA_SECTION(nx12,".SDRAM$heap")
#pragma DATA_SECTION(win,".SDRAM$heap")
#pragma DATA_SECTION(win1,".SDRAM$heap")
#pragma DATA_SECTION(win12,".SDRAM$heap")
#pragma DATA_SECTION(w,".temp")
#pragma DATA_SECTION(samples,".temp")
#pragma DATA_SECTION(deny,".new")
#pragma DATA_SECTION(grant,".new")
typedef struct {float real, imag;} COMPLEX;
void FFT_init(float *);
void FFT(COMPLEX *, int );
int maxim(float *, int );
float win[256], win1[2500], win12[2500];
float x[10000], spec[256],deny[8000],grant[8000];
float nx1[2500],nx12[2500];
COMPLEX w[PTS]; ];
COMPLEX samples[PTS];
int i = 0, j, temp, N, k, d[12];
/* Initialization of the codec*/
DSK6713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
0x00e0, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \
0x00e0, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume*/
0x0015, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */ \
0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */ \
0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */ \
0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */ \
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */ \
0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};
void main()
{
DSK6713_AIC23_CodecHandle hCodec;
Uint32 l_input, r_input,l_output, r_output;
int i;
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0, &config);
DSK6713_AIC23_setFreq(hCodec, 1);
for(i = 0 ; i < 10000 ; i++)
{
while (!DSK6713_AIC23_read(hCodec, &l_input));
while (!DSK6713_AIC23_read(hCodec, &r_input));
x[i]=l_input;
l_output=x[i];
r_output=x[i];
while (!DSK6713_AIC23_write(hCodec, l_output));
while (!DSK6713_AIC23_write(hCodec, r_output));
}
DSK6713_AIC23_closeCodec(hCodec);
i = 0;
while(abs(x[i]) < 0.12)
i++;
temp = i;
for(j = 0 ; j < 10000 - temp ; j++)
x[j] = x[i++];
for(j = 10000 - temp ; j < 10000 ; j++)
x[j] = 0;
for(i = 0 ; i < 256 ; i++)
win[i] = 0.53836 - 0.46164 * cos((2 * 3.14 * i)/(256));
hCodec = DSK6713_AIC23_openCodec(0, &config);
DSK6713_AIC23_setFreq(hCodec, 1);
for(i = 0 ; i < 2500 ; i++)
{
l_output=x[i];
r_output=l_output;
/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec, l_output));
/* Send a sample to the right channel */
while (!DSK6713_AIC23_write(hCodec, r_output));
}
DSK6713_AIC23_closeCodec(hCodec);
for(k = 0 ; k < 11 ; k++)
{
for(j = 0 ; j < (200 * k) ; j++)
win1[j] = 0;
for(j = (200 * k) ; j < ((200 * k) + 256) ; j++)
win1[j] = win[j - (200 * k)];
for(j = ((200 * k) + 256) ; j < 2500 ; j++)
win1[j]=0;
for(i = 0 ; i < 2500 ; i++)
nx1[i] = x[i] * win1[i];
i = 0;
while(nx1[i] == 0)
i++;
temp = i;
for(j = 0 ; j < 2500 - temp ; j++)
nx1[j] = nx1[i++];
for(j = 2500 - temp ; j < 2500 ; j++)
nx1[j] = 0;
FFT_init(nx1);
d[k] = maxim(spec, 256);
}
for(j = 0 ; j < 2244 ; j++)
win12[j]=0;
for(j = 2244 ; j < 2500 ; j++)
win12[j] = win[j - 2244];
for(i = 0 ; i < 2500;i++)
nx12[i] = x[i] * win12[i];
i = 0;
while(nx12[i] == 0)
i++;
temp = i;
for(j = 0 ; j < 2500 - temp ; j++)
nx12[j] = nx12[i++];
for(j = 2500 - temp ; j < 2500 ; j++)
nx12[j] = 0;
FFT_init(nx12);
d[11] = maxim(spec, 256);
}
void FFT_init(float *x1)
{
for(i = 0 ; i < PTS ; i++)
{
w[i].real = cos(2 * PI * i / (PTS * 2.0));
w[i].imag = -sin(2 * PI * i / (PTS * 2.0));
}
for(i = 0 ; i < PTS ; i++)
{
samples[i].real = 0;
samples[i].imag = 0;
}
for(i = 0 ; i < PTS ; i++)
{
samples[i].real = x1[i];
}
for(i = 0 ; i < PTS ; i++)
samples[i].imag = 0;
FFT(samples, PTS);
for(i = 0 ; i < PTS ; i++)
{
spec[i] = sqrt(samples[i].real * samples[i].real + samples[i].imag *
samples[i].imag);
}
return;
}
void FFT(COMPLEX *Y, int N)
{
COMPLEX temp1, temp2;
int i, j, k;
int upper_leg, lower_leg;
int leg_diff;
int num_stages = 0;
int index, step;
i = 1;
do
{
num_stages += 1;
i = i * 2;
}while(i != N);
leg_diff = N / 2;
step = (PTS * 2) / N;
for(i = 0; i < num_stages ; i++)
{
index = 0;
for(j = 0 ; j < leg_diff ; j++)
{
for(upper_leg = j ; upper_leg < N ; upper_leg += (2 * leg_diff))
{
lower_leg = upper_leg + leg_diff;
temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
(Y[lower_leg]).real = temp2.real * (w[index]).real - temp2.imag *
(w[index]).imag;
(Y[lower_leg]).imag = temp2.real * (w[index]).imag + temp2.imag *
(w[index]).real;
83
(Y[upper_leg]).real = temp1.real;
(Y[upper_leg]).imag = temp1.imag;
}
index += step;
}
leg_diff = leg_diff / 2;
step *= 2;
}
j = 0;
for(i = 0 ; i < (N-1) ; i++)
{
k = N / 2;
while(k <= j)
{
j = j - k;
k = k / 2;
}
j = j + k;
if(i < j)
{
temp1.real = (Y[j]).real;
temp1.imag = (Y[j]).imag;
(Y[j]).real = (Y[i]).real;
(Y[j]).imag = (Y[i]).imag;
(Y[i]).real = temp1.real;
(Y[i]).imag = temp1.imag;
}
}
return;
}
int maxim(float *a, int length)
{
float temp;
int pos;
temp = a[1];
pos = 1;
for(i = 2 ; i < length / 2 ; i++)
{
if(temp < a[i])
{
temp = a[i];
pos = i;
}
}
return pos;
}
issues:--
1)when i execute this file i m not getting any compilation errors but during
linking i have got 2 errors sayin .temp and .new are not specified sections, so
i replaced the with .mem , i dint get any linking error this time but could not
get the o/p as well... is it ok to replace them with .mem or shud i create new
data sections in IRAM? if so how do i do that?
2) another problem is that wen i check the contents of win,win1 which is are
variables of this code in view> memory i m repeatedly getting garbage
values..
how can i get the correct values??
pls help me wid this.
how to create data section in IRAM using tms320c6713
Started by ●April 4, 2012
Reply by ●April 4, 20122012-04-04
Maanvitha,
There are a few things in the code that will not work as they are written
(well, they do something, but probably not what you are trying to do)
For instance the sequence "< !"
as an example, "< !PTS", where PTS is a #define value of 256
this means '< !256'
This resolves to (on my computer)
1.844674407 * 10000000000000000000
Very likely not what you were planning to use.
There are a few other details...
--several items are set to unknown locations in the heap.
The heap is for malloc/free (new/delete) operations.
There is a memory section named '.temp' and variables named 'temp'
There is a memory section named '.new' and a built in command 'new'.
This duplication can lead to confusion should not be used.
Your email requests how to create memory areas in IRAM.
To make that easy, a copy of the .con (configuration) file needs to be posted.
The normal reason to use the #pragma DATA_SECTION() is to locate a specific data
block at a known address or into a known memory segment.
(typically, putting a data block into internal/external memory or
to place a 'struct' over the memory mapped address of a peripheral register group)
Note: 'win', etc are arrays of float values.
You will need the specific format of a float value and how that value is
'normalised' in memory to be able to make sense of the memory contents.
Hope this helps.
R. Williams
---------- Original Message -----------
From: Maanvitha Kaneboina
To: "c..."
Sent: Tue, 3 Apr 2012 07:13:29 -0700 (PDT)
Subject: [c6x] how to create data section in IRAM using tms320c6713
> hi,
> i am trying to execute a code w.r.t speech recognition on tms320c6713
> kit in ccsv3.1 . the following code is a part of it.
>
> #define FS 10000
> #define PTS 256
> #define PI 3.14159265358979
> #pragma DATA_SECTION(x,".SDRAM$heap")
> #pragma DATA_SECTION(spec,".temp")
> #pragma DATA_SECTION(nx1,".SDRAM$heap")
> #pragma DATA_SECTION(nx12,".SDRAM$heap")
> #pragma DATA_SECTION(win,".SDRAM$heap")
> #pragma DATA_SECTION(win1,".SDRAM$heap")
> #pragma DATA_SECTION(win12,".SDRAM$heap")
> #pragma DATA_SECTION(w,".temp")
> #pragma DATA_SECTION(samples,".temp")
> #pragma DATA_SECTION(deny,".new")
> #pragma DATA_SECTION(grant,".new")
> typedef struct {float real, imag;} COMPLEX;
> void FFT_init(float *);
> void FFT(COMPLEX *, int );
> int maxim(float *, int );
> float win[256], win1[2500], win12[2500];
> float x[10000], spec[256],deny[8000],grant[8000];
> float nx1[2500],nx12[2500];
> COMPLEX w[PTS]; ];
> COMPLEX samples[PTS];
> int i = 0, j, temp, N, k, d[12];
> /* Initialization of the codec*/
> DSK6713_AIC23_Config config = { \
> 0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */
> \ 0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel
> volume */\ 0x00e0, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone
> volume */ \ 0x00e0, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel
> headphone volume*/ 0x0015, /* 4 DSK6713_AIC23_ANAPATH Analog audio
> path control */ \ 0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio
> path control */ \ 0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down
> control */ \ 0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface
> format */ \ 0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control
> */ \ 0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */
> \ };
void main()
{
DSK6713_AIC23_CodecHandle hCodec; Uint32 l_input,
> r_input,l_output, r_output; int i; DSK6713_init();
hCodec > DSK6713_AIC23_openCodec(0, &config); DSK6713_AIC23_setFreq(hCodec, 1);
> for(i = 0 ; i < 10000 ; i++)
{
while (!DSK6713_AIC23_read(hCodec, &l_input));
while (!DSK6713_AIC23_read(hCodec, &r_input));
x[i]=l_input;
l_output=x[i];
r_output=x[i];
while (!DSK6713_AIC23_write(hCodec, l_output));
while (!DSK6713_AIC23_write(hCodec, r_output));
} // end for()
> DSK6713_AIC23_closeCodec(hCodec);
> i = 0;
> while(abs(x[i]) < 0.12) i++;
> temp = i;
> for(j = 0 ; j < 10000 - temp ; j++) x[j] = x[i++];
> for(j = 10000 - temp ; j < 10000 ; j++) x[j] = 0;
> for(i = 0 ; i < 256 ; i++) win[i] = 0.53836 - 0.46164 * cos((2 * 3.14 * i)/(256));
> hCodec = DSK6713_AIC23_openCodec(0, &config);
> DSK6713_AIC23_setFreq(hCodec, 1);
for(i = 0 ; i < 2500 ; i++)
{
> l_output=x[i];
> r_output=l_output;
> /* Send a sample to the left channel */
> while (!DSK6713_AIC23_write(hCodec, l_output));
> /* Send a sample to the right channel */
> while (!DSK6713_AIC23_write(hCodec, r_output));
> } // end for()
> DSK6713_AIC23_closeCodec(hCodec);
for(k = 0 ; k < 11 ; k++)
{
> for(j = 0 ; j < (200 * k) ; j++) win1[j] = 0;
> for(j = (200 * k) ; j < ((200 * k) + 256) ; j++) win1[j] = win[j - (200 * k)];
> for(j = ((200 * k) + 256) ; j < 2500 ; j++) win1[j]=0;
> for(i = 0 ; i < 2500 ; i++) nx1[i] = x[i] * win1[i];
> i = 0;
> while(nx1[i] == 0) i++;
> temp = i;
> for(j = 0 ; j < 2500 - temp ; j++) nx1[j] = nx1[i++];
> for(j = 2500 - temp ; j < 2500 ; j++) nx1[j] = 0;
> FFT_init(nx1);
> d[k] = maxim(spec, 256);
} // end for()
> for(j = 0 ; j < 2244 ; j++) win12[j]=0;
> for(j = 2244 ; j < 2500 ; j++) win12[j] = win[j - 2244];
> for(i = 0 ; i < 2500;i++) nx12[i] = x[i] * win12[i];
> i = 0;
> while(nx12[i] == 0) i++;
> temp = i;
> for(j = 0 ; j < 2500 - temp ; j++) nx12[j] = nx12[i++];
> for(j = 2500 - temp ; j < 2500 ; j++) nx12[j] = 0;
> FFT_init(nx12);
> d[11] = maxim(spec, 256);
} // end of function main()
void FFT_init(float *x1)
{
> for(i = 0 ; i < PTS ; i++)
> {
> w[i].real = cos(2 * PI * i / (PTS * 2.0));
> w[i].imag = -sin(2 * PI * i / (PTS * 2.0));
> } // end for()
for(i = 0 ; i < PTS ; i++)
> {
> samples[i].real = 0;
> samples[i].imag = 0;
> } // end for()
> for(i = 0 ; i < PTS ; i++)
> {
> samples[i].real = x1[i];
> } // end for()
> for(i = 0 ; i < PTS ; i++) samples[i].imag = 0;
> FFT(samples, PTS);
> for(i = 0 ; i < PTS ; i++)
> {
> spec[i] = sqrt(samples[i].real * samples[i].real + samples[i].imag *
> samples[i].imag);
> }
> return;
> } // end of function FFT_init()
> void FFT(COMPLEX *Y, int N)
> {
> COMPLEX temp1, temp2;
> int i, j, k;
> int upper_leg, lower_leg;
> int leg_diff;
> int num_stages = 0;
> int index, step;
> i = 1;
> do
> {
> num_stages += 1;
> i = i * 2;
> } while(i != N); // probably should be '< N'
> leg_diff = N / 2;
> step = (PTS * 2) / N;
> for(i = 0; i < num_stages ; i++)
> {
> index = 0;
> for(j = 0 ; j < leg_diff ; j++)
> {
// note: 2*leg_diff is the same as N, so be much faster to just use N
> for(upper_leg = j ; upper_leg < N ; upper_leg += (2 * leg_diff))
> {
> lower_leg = upper_leg + leg_diff;
> temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
> temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
> temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
> temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
> (Y[lower_leg]).real = temp2.real * (w[index]).real - temp2.imag *
> (w[index]).imag;
> (Y[lower_leg]).imag = temp2.real * (w[index]).imag + temp2.imag *
> (w[index]).real;
> 83 // RKW: what is this?
> (Y[upper_leg]).real = temp1.real;
> (Y[upper_leg]).imag = temp1.imag;
> } // end for( upper_leg )
> index += step;
> } // end for( j )
> leg_diff = leg_diff / 2;
> step *= 2;
> } // end for( i )
> j = 0;
> for(i = 0 ; i < (N-1) ; i++)
> {
> k = N / 2;
> while(k <= j)
> {
> j = j - k;
> k = k / 2;
> } // end while( k<=j )
> j = j + k;
> if(i < j)
> {
> temp1.real = (Y[j]).real;
> temp1.imag = (Y[j]).imag;
> (Y[j]).real = (Y[i]).real;
> (Y[j]).imag = (Y[i]).imag;
> (Y[i]).real = temp1.real;
> (Y[i]).imag = temp1.imag;
> } // end if( i > } // end for( i )
> return;
> } // end of function FFT()
>
> int maxim(float *a, int length)
> {
> float temp;
> int pos;
> temp = a[1];
> pos = 1;
> for(i = 2 ; i < length / 2 ; i++)
> {
> if(temp < a[i])
> {
> temp = a[i];
> pos = i;
> } // end if()
> } // end for( i )
> return pos;
> } // end of function maxim()
>
> issues:--
> 1) when i execute this file i m not getting any compilation errors but
> during linking i have got 2 errors sayin .temp and .new are not
> specified sections, so i replaced the with .mem , i dint get any
> linking error this time but could not get the o/p as well... is it ok
> to replace them with .mem or shud i create new data sections in
> IRAM? if so how do i do that?
>
> 2) another problem is that wen i check the contents of win,win1 which
> is are variables of this code in view> memory i m repeatedly getting
> garbage values.. how can i get the correct values?? pls help me wid this.
------- End of Original Message -------
_____________________________________
There are a few things in the code that will not work as they are written
(well, they do something, but probably not what you are trying to do)
For instance the sequence "< !"
as an example, "< !PTS", where PTS is a #define value of 256
this means '< !256'
This resolves to (on my computer)
1.844674407 * 10000000000000000000
Very likely not what you were planning to use.
There are a few other details...
--several items are set to unknown locations in the heap.
The heap is for malloc/free (new/delete) operations.
There is a memory section named '.temp' and variables named 'temp'
There is a memory section named '.new' and a built in command 'new'.
This duplication can lead to confusion should not be used.
Your email requests how to create memory areas in IRAM.
To make that easy, a copy of the .con (configuration) file needs to be posted.
The normal reason to use the #pragma DATA_SECTION() is to locate a specific data
block at a known address or into a known memory segment.
(typically, putting a data block into internal/external memory or
to place a 'struct' over the memory mapped address of a peripheral register group)
Note: 'win', etc are arrays of float values.
You will need the specific format of a float value and how that value is
'normalised' in memory to be able to make sense of the memory contents.
Hope this helps.
R. Williams
---------- Original Message -----------
From: Maanvitha Kaneboina
To: "c..."
Sent: Tue, 3 Apr 2012 07:13:29 -0700 (PDT)
Subject: [c6x] how to create data section in IRAM using tms320c6713
> hi,
> i am trying to execute a code w.r.t speech recognition on tms320c6713
> kit in ccsv3.1 . the following code is a part of it.
>
> #define FS 10000
> #define PTS 256
> #define PI 3.14159265358979
> #pragma DATA_SECTION(x,".SDRAM$heap")
> #pragma DATA_SECTION(spec,".temp")
> #pragma DATA_SECTION(nx1,".SDRAM$heap")
> #pragma DATA_SECTION(nx12,".SDRAM$heap")
> #pragma DATA_SECTION(win,".SDRAM$heap")
> #pragma DATA_SECTION(win1,".SDRAM$heap")
> #pragma DATA_SECTION(win12,".SDRAM$heap")
> #pragma DATA_SECTION(w,".temp")
> #pragma DATA_SECTION(samples,".temp")
> #pragma DATA_SECTION(deny,".new")
> #pragma DATA_SECTION(grant,".new")
> typedef struct {float real, imag;} COMPLEX;
> void FFT_init(float *);
> void FFT(COMPLEX *, int );
> int maxim(float *, int );
> float win[256], win1[2500], win12[2500];
> float x[10000], spec[256],deny[8000],grant[8000];
> float nx1[2500],nx12[2500];
> COMPLEX w[PTS]; ];
> COMPLEX samples[PTS];
> int i = 0, j, temp, N, k, d[12];
> /* Initialization of the codec*/
> DSK6713_AIC23_Config config = { \
> 0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */
> \ 0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel
> volume */\ 0x00e0, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone
> volume */ \ 0x00e0, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel
> headphone volume*/ 0x0015, /* 4 DSK6713_AIC23_ANAPATH Analog audio
> path control */ \ 0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio
> path control */ \ 0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down
> control */ \ 0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface
> format */ \ 0x0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control
> */ \ 0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */
> \ };
void main()
{
DSK6713_AIC23_CodecHandle hCodec; Uint32 l_input,
> r_input,l_output, r_output; int i; DSK6713_init();
hCodec > DSK6713_AIC23_openCodec(0, &config); DSK6713_AIC23_setFreq(hCodec, 1);
> for(i = 0 ; i < 10000 ; i++)
{
while (!DSK6713_AIC23_read(hCodec, &l_input));
while (!DSK6713_AIC23_read(hCodec, &r_input));
x[i]=l_input;
l_output=x[i];
r_output=x[i];
while (!DSK6713_AIC23_write(hCodec, l_output));
while (!DSK6713_AIC23_write(hCodec, r_output));
} // end for()
> DSK6713_AIC23_closeCodec(hCodec);
> i = 0;
> while(abs(x[i]) < 0.12) i++;
> temp = i;
> for(j = 0 ; j < 10000 - temp ; j++) x[j] = x[i++];
> for(j = 10000 - temp ; j < 10000 ; j++) x[j] = 0;
> for(i = 0 ; i < 256 ; i++) win[i] = 0.53836 - 0.46164 * cos((2 * 3.14 * i)/(256));
> hCodec = DSK6713_AIC23_openCodec(0, &config);
> DSK6713_AIC23_setFreq(hCodec, 1);
for(i = 0 ; i < 2500 ; i++)
{
> l_output=x[i];
> r_output=l_output;
> /* Send a sample to the left channel */
> while (!DSK6713_AIC23_write(hCodec, l_output));
> /* Send a sample to the right channel */
> while (!DSK6713_AIC23_write(hCodec, r_output));
> } // end for()
> DSK6713_AIC23_closeCodec(hCodec);
for(k = 0 ; k < 11 ; k++)
{
> for(j = 0 ; j < (200 * k) ; j++) win1[j] = 0;
> for(j = (200 * k) ; j < ((200 * k) + 256) ; j++) win1[j] = win[j - (200 * k)];
> for(j = ((200 * k) + 256) ; j < 2500 ; j++) win1[j]=0;
> for(i = 0 ; i < 2500 ; i++) nx1[i] = x[i] * win1[i];
> i = 0;
> while(nx1[i] == 0) i++;
> temp = i;
> for(j = 0 ; j < 2500 - temp ; j++) nx1[j] = nx1[i++];
> for(j = 2500 - temp ; j < 2500 ; j++) nx1[j] = 0;
> FFT_init(nx1);
> d[k] = maxim(spec, 256);
} // end for()
> for(j = 0 ; j < 2244 ; j++) win12[j]=0;
> for(j = 2244 ; j < 2500 ; j++) win12[j] = win[j - 2244];
> for(i = 0 ; i < 2500;i++) nx12[i] = x[i] * win12[i];
> i = 0;
> while(nx12[i] == 0) i++;
> temp = i;
> for(j = 0 ; j < 2500 - temp ; j++) nx12[j] = nx12[i++];
> for(j = 2500 - temp ; j < 2500 ; j++) nx12[j] = 0;
> FFT_init(nx12);
> d[11] = maxim(spec, 256);
} // end of function main()
void FFT_init(float *x1)
{
> for(i = 0 ; i < PTS ; i++)
> {
> w[i].real = cos(2 * PI * i / (PTS * 2.0));
> w[i].imag = -sin(2 * PI * i / (PTS * 2.0));
> } // end for()
for(i = 0 ; i < PTS ; i++)
> {
> samples[i].real = 0;
> samples[i].imag = 0;
> } // end for()
> for(i = 0 ; i < PTS ; i++)
> {
> samples[i].real = x1[i];
> } // end for()
> for(i = 0 ; i < PTS ; i++) samples[i].imag = 0;
> FFT(samples, PTS);
> for(i = 0 ; i < PTS ; i++)
> {
> spec[i] = sqrt(samples[i].real * samples[i].real + samples[i].imag *
> samples[i].imag);
> }
> return;
> } // end of function FFT_init()
> void FFT(COMPLEX *Y, int N)
> {
> COMPLEX temp1, temp2;
> int i, j, k;
> int upper_leg, lower_leg;
> int leg_diff;
> int num_stages = 0;
> int index, step;
> i = 1;
> do
> {
> num_stages += 1;
> i = i * 2;
> } while(i != N); // probably should be '< N'
> leg_diff = N / 2;
> step = (PTS * 2) / N;
> for(i = 0; i < num_stages ; i++)
> {
> index = 0;
> for(j = 0 ; j < leg_diff ; j++)
> {
// note: 2*leg_diff is the same as N, so be much faster to just use N
> for(upper_leg = j ; upper_leg < N ; upper_leg += (2 * leg_diff))
> {
> lower_leg = upper_leg + leg_diff;
> temp1.real = (Y[upper_leg]).real + (Y[lower_leg]).real;
> temp1.imag = (Y[upper_leg]).imag + (Y[lower_leg]).imag;
> temp2.real = (Y[upper_leg]).real - (Y[lower_leg]).real;
> temp2.imag = (Y[upper_leg]).imag - (Y[lower_leg]).imag;
> (Y[lower_leg]).real = temp2.real * (w[index]).real - temp2.imag *
> (w[index]).imag;
> (Y[lower_leg]).imag = temp2.real * (w[index]).imag + temp2.imag *
> (w[index]).real;
> 83 // RKW: what is this?
> (Y[upper_leg]).real = temp1.real;
> (Y[upper_leg]).imag = temp1.imag;
> } // end for( upper_leg )
> index += step;
> } // end for( j )
> leg_diff = leg_diff / 2;
> step *= 2;
> } // end for( i )
> j = 0;
> for(i = 0 ; i < (N-1) ; i++)
> {
> k = N / 2;
> while(k <= j)
> {
> j = j - k;
> k = k / 2;
> } // end while( k<=j )
> j = j + k;
> if(i < j)
> {
> temp1.real = (Y[j]).real;
> temp1.imag = (Y[j]).imag;
> (Y[j]).real = (Y[i]).real;
> (Y[j]).imag = (Y[i]).imag;
> (Y[i]).real = temp1.real;
> (Y[i]).imag = temp1.imag;
> } // end if( i > } // end for( i )
> return;
> } // end of function FFT()
>
> int maxim(float *a, int length)
> {
> float temp;
> int pos;
> temp = a[1];
> pos = 1;
> for(i = 2 ; i < length / 2 ; i++)
> {
> if(temp < a[i])
> {
> temp = a[i];
> pos = i;
> } // end if()
> } // end for( i )
> return pos;
> } // end of function maxim()
>
> issues:--
> 1) when i execute this file i m not getting any compilation errors but
> during linking i have got 2 errors sayin .temp and .new are not
> specified sections, so i replaced the with .mem , i dint get any
> linking error this time but could not get the o/p as well... is it ok
> to replace them with .mem or shud i create new data sections in
> IRAM? if so how do i do that?
>
> 2) another problem is that wen i check the contents of win,win1 which
> is are variables of this code in view> memory i m repeatedly getting
> garbage values.. how can i get the correct values?? pls help me wid this.
------- End of Original Message -------
_____________________________________