This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

real time programming

i'm writing the code for real time computation of the supply for harmonics using dft.

to compute dft i have to take samples of the supply voltage but im not getting proper samples...can u help me with the part to take samples,this is the code

#include "xyz2cfg.h"
#include "c:\ccstudio_v3.1\c6000\dsk6713\include\dsk6713.h"
#include "c:\ccstudio_v3.1\c6000\dsk6713\include\dsk6713_aic23.h"

DSK6713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */ \
0x0011, /* 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 */ \
};


/*
* main() - Main code routine, initializes BSL and generates tone
*/

void main()
{
int n=0,i=0;
int a[8]={0,0,0,0,0,0,0,0};
DSK6713_AIC23_CodecHandle hCodec;

Uint32 l_input, r_input,l_output, r_output;

/* Initialize the board support library, must be called first */
DSK6713_init();

/* Start the codec */
hCodec = DSK6713_AIC23_openCodec(0, &config);

DSK6713_AIC23_setFreq(hCodec, 1);


while(1)
{ /* Read a sample to the left channel */
while (!DSK6713_AIC23_read(hCodec, &l_input));

if(n%25==0)
{
a[i++]=l_input;
l_output=l_input;
printf("\n%d",a[i-1]);

/* Send a sample to the left channel */
while (!DSK6713_AIC23_write(hCodec, l_output));
}

if(i==7)
{
for(i=0;i<7;i++)
{a[i]=a[i+1];
i++;
}}
/* Read a sample to the right channel */
while (!DSK6713_AIC23_read(hCodec, &r_input));


n++;

}

/* Close the codec */
DSK6713_AIC23_closeCodec(hCodec);
}


  • Smriti,

    The random indentation of the code and the placement of the curly braces makes it hard for me to follow your program. More comments and accurate comments would make it much easier, also.

    Please find one of the sample programs that comes with the DSK to start with. Make sure you can at least get data in and put data out before doing other things.

    I do not know if there is a problem with not writing both samples when you are reading both samples. They timing might be off, or it may cause underrun errors, or data errors. I do not know. It seems strange to do it this way.

    I cannot figure out what you are doing with the "i" variable.

    So please start with a working example and make sure you can justify your changes like this.

    Regards,
    RandyP