06-05-2011, 04:09 PM
Code:
#include "xyzcfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
float filter_Coeff[] ={0.000000,-0.001591,-0.002423,0.000000,0.005728,
0.011139,0.010502,-0.000000,-0.018003,-0.033416,-0.031505,0.000000,
0.063010,0.144802,0.220534,0.262448,0.220534,0.144802,0.063010,0.000000,
-0.031505,-0.033416,-0.018003,-0.000000,0.010502,0.011139,0.005728,
0.000000,-0.002423,-0.001591,0.000000 };
static short in_buffer[100];
DSK6713_AIC23_Config config = {\
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline 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()
{
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));
/* Read a sample to the right channel */
while (!DSK6713_AIC23_read(hCodec, &r_input));
l_output=(Int16)FIR_FILTER(&filter_Coeff ,l_input);
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));
}
/* Close the codec */
DSK6713_AIC23_closeCodec(hCodec);
}
signed int FIR_FILTER(float * h, signed int x)
{
int i=0;
signed long output=0;
in_buffer[0] = x; /* new input at buffer[0] */
for(i=51;i>0;i--)
in_buffer[i] = in_buffer[i-1]; /* shuffle the buffer */
for(i=0;i<51;i++)
output = output + h[i] * in_buffer[i];
return(output);
}
HOW TO PROCEED:
1. Connect a Signal Generator/audio input to the LINE IN Socket or connect a microphone to the MIC IN Socket.
Note:- To use microphone input change the analog audio path control register value (Register no. 4) in Codec Configuration settings of the Source file (Fir.c) from 0x0011 to 0x0015.
2. Connect CRO/Desktop Speakers to the Socket Provided for LINE OUT or connect a headphone to the Headphone out Socket.
3. Now Switch on the DSK and Bring Up Code Composer Studio on the PC.
4. Use the Debug Connect menu option to open a debug connection to the DSK board
5. Create a new project with name Fir.pjt.
6. Open the File Menu new DSP/BIOS Configuration select
“dsk6713.cdb” and save it as “xyz.cdb”
7. Add “xyz.cdb” to the current project.
Project Add files to project xyz.cdb
8. Automatically three files are added in the Generated file folder in project pane
xyzcfg.cmd Command and linking file
xyzcfg.s62 optimized assembly code for configuration
xyzcfg_c.c Chip support initialization
9. Open the File Menu new Source file
10. Type the code in editor window. Save the file in project folder. (Eg: Codec.c).
Important note: Save your source code with preferred language extension. For ASM codes save the file as code(.asm) For C and C++ codes code (*.c,*.cpp) respectively.
11. Add the saved “Fir.c” file to the current project which has the main function and calls all the other necessary routines.
Project Add files to Project Codec.c
12. Add the library file “dsk6713bsl.lib” to the current project
Path “C:\CCStudio_v3.1\C6000\dsk6713\lib\dsk6713bsl.lib”
13. Copy header files “dsk6713.h” and “dsk6713_aic23.h” from and paste it in current project folder.
C:\CCStudio_v3.1\C6000\dsk6713\include.
14. Add the header file generated within xyzcfg_c.c to Fir.c
Note:- Double click on xyzcfg_c.c Copy the first line header (eg.xyzcfg.h) and paste that in source file (eg.Fir.c).
15. Compile the program using the ‘Project-compile’ pull down menu or by
Clicking the shortcut icon on the left side of program window.
16. Build the program using the ‘Project-Build’ pull down menu or by clicking the shortcut icon on the left side of program window.
17. Load the program (Codec.out) in program memory of DSP chip using the
‘File-load program’ pull down menu.
18. Debug Run
MATLAB GENERATED FREQUENCY RESPONSE
High Pass FIR filter(Fc= 800Hz).