Tool/software: Code Composer Studio
Dear TI,
I recently started working on tmdxlcdk6748, using ccs.
I want to pass a summed signal of two sine waves and eliminate one of it using fir filter. I produced the sample values of the summed signal in matlab.
I have written the code but Im unable to get an output. I added the right files and included the right paths too. The build is fine, so is the debug session. Once I get the output in console, it is wrong when I compare it to the answer in matlab. My frequency spectrums of, the matlab and ccs ouput are different.
Here is the code and the console.
CODE:
#include "L138_LCDK_aic3106_init.h"
#define N 48
float h[N] = {0.0010, -0.0149, -0.0074, -0.0061, -0.0033, 0.0010, 0.0061, 0.0109, 0.0138, 0.0136, 0.0096, 0.0019, -0.0083, -0.0189,
-0.0272, -0.0303, -0.0258, -0.0123, 0.0099, 0.0390, 0.0719, 0.1043, 0.1316, 0.1498, 0.1562, 0.1498, 0.1316, 0.1043,
0.0719, 0.0390, 0.0099, -0.0123, -0.0258, -0.0303, -0.0272, -0.0189, -0.0083, 0.0019, 0.0096, 0.0136, 0.0138, 0.0109,
0.0061, 0.0010, -0.0033, -0.0061, -0.0074, -0.0149};// FILTER CO-EFFICIENTS
int16_t sine_table[N] ={0, 1.0898, 1.7071, 1.6310, 1.0000, 0.2168, -0.2929, -0.3244, -0.0000,
0.3244, 0.2929, -0.2168, -1.0000, -1.6310, -1.7071, -1.0898, -0.0000,
1.0898, 1.7071, 1.6310, 1.0000, 0.2168, -0.2929, -0.3244, -0.0000, 0.3244,
0.2929, -0.2168, -1.0000, -1.6310, -1.7071, -1.0898, -0.0000, 1.0898, 1.7071,
1.6310, 1.0000, 0.2168, -0.2929, -0.3244, -0.0000, 0.3244, 0.2929, -0.2168,
-1.000, -1.6310, -1.7071, -1.0898};
int sine_ptr = 0; // pointer into lookup table
float x[N]; // filter delay line
float y[N]; // filter delay line
interrupt void interrupt4(void) // interrupt service routine
{
int i;
float yn = 0.0;
x[i] = sine_table[sine_ptr];
sine_ptr = (sine_ptr+1)%N;
for (i=0 ; i<N ; i++)
{ // compute filter output
yn += h[i]*x[i];
printf("yn=%f\n",yn); }
for (i=(N-1) ; i>0 ; i--) // shift delay line
x[i] = x[i-1];
output_left_sample((uint16_t)(yn));
return;
}
int main(void) //interrupt void interrupt4(void) interrupt service routine
{
L138_initialise_intr(FS_16000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_LINE_INPUT);
while(1);
}
CONSOLE:
[C674X_0] yn=-0.000000
yn=-0.000000
yn=-0.000000
yn=-0.000000
yn=-0.000000
yn=-0.000000
yn=-0.000000
yn=3681929415830794572830.200195
yn=3681929415830794572830.200195
yn=3681929415830794572830.200195
yn=-363324968346958816051483154.296875
yn=-363324968346958816051483154.296875
yn=-363324488731613039970397949.218750
yn=-363324488731613039970397949.218750
yn=-480375831387631058692932128.906250
yn=-480373728458806812763214111.328125
yn=-480370740086266696453094482.421875
yn=-480370740086266696453094482.421875
yn=-478134810237092375755310058.593750
yn=-478134810237092375755310058.593750
yn=-478134810237092375755310058.593750
yn=-478134810237092375755310058.593750
yn=-478134810237092375755310058.593750
yn=-478134810237092375755310058.593750
yn=-478134810237092375755310058.593750
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
yn=Nan
This is my matlab output:
y =
Columns 1 through 9
0 0.0011 -0.0145 -0.0319 -0.0426 -0.0408 -0.0254 -0.0007 0.0263
Columns 10 through 18
0.0484 0.0609 0.0622 0.0528 0.0333 0.0040 -0.0344 -0.0782 -0.1183
Columns 19 through 27
-0.1402 -0.1270 -0.0641 0.0545 0.2230 0.4228 0.6261 0.8016 0.9207
Columns 28 through 36
0.9617 0.9122 0.7698 0.5427 0.2501 -0.0514 -0.3608 -0.6389 -0.8389
Columns 37 through 45
-0.9182 -0.8522 -0.6448 -0.3304 0.0343 0.3853 0.6670 0.8418 0.8936
Columns 46 through 48
0.8229 0.6416 0.3695
Any help will be highly appreciated.
Thank you,
Ria.