Tms320c6713 User Manual
Tms320c6713 User Manual
Tms320c6713 User Manual
USER MANUAL
EdGate Technologies,
th
No.68, 15 cross, 1st Block,
R.T. Nagar, Bangalore-32
EdGate Technologies
CONTENTS
DSK FEATURES
INSTALLATION PROCEDURE
PASS/HIGH
PASS)USING
EdGate Technologies
TMS320C6713 DSK
Package Contents
The C6713 DSK builds on TI's industry-leading line of low cost, easy-to-use DSP
Starter Kit (DSK) development boards. The high-performance board features the
TMS320C6713 floating-point DSP. Capable of performing 1350 million floating -point
operations per second (MFLOPS), the C6713 DSP makes the C6713 DSK the most
powerful DSK development board.
The DSK is USB port interfaced platform that allows to efficiently develop and test
applications for the C6713. The DSK consists of a C6713-based printed circuit board that
will serve as a hardware reference design for TIs customers products. With extensive
host PC and target DSP software support, including bundled TI tools, the DSK provides
ease-of-use and capabilities that are attractive to DSP engineers.
The following checklist details items that are shipped with the C6711 DSK kit.
TMS320C6713 DSK
Other hardware
EdGate Technologies
CD-ROM
The C6713 DSK has a TMS320C6713 DSP onboard that allows full-speed verification
of code with Code Composer Studio. The C6713 DSK provides:
A USB Interface
SDRAM and ROM
An analog interface circuit for Data conversion (AIC)
An I/O port
Embedded JTAG emulation support
Connectors on the C6713 DSK provide DSP external memory interface (EMIF) and
peripheral signals that enable its functionality to be expanded with custom or third party
daughter boards.
The DSK provides a C6713 hardware reference design that can assist you in the
development of your own C6713-based products. In addition to providing a reference for
interfacing the DSP to various types of memories and peripherals, the design also
addresses power, clock, JTAG, and parallel peripheral interfaces.
The C6713 DSK includes a stereo codec. This analog interface circuit (AIC) has the
following characteristics:
High-Performance Stereo Codec
90-dB SNR Multibit Sigma-Delta ADC (A-weighted at 48 kHz)
1.42 V 3.6 V Core Digital Supply: Compatible With TI C54x DSP Core
Voltages
2.7 V 3.6 V Buffer and Analog Supply: Compatible Both TI C54x DSP
Buffer Voltages
8-kHz 96-kHz Sampling-Frequency Support
Software Control Via TI McBSP-Compatible Multiprotocol Serial Port
I 2 C-Compatible and SPI-Compatible Serial-Port Protocols
16/20/24/32-Bit
Word
Lengths
EdGate Technologies
EdGate Technologies
Device Configuration
Up to 16 transmit pins
Serial-Peripheral-Interface (SPI)
High-Speed TDM Interface
AC97 Interface
) Boundary-Scan-Compatible
IEEE-1149.1 (JTAG
Package
Options:
EdGate Technologies
INSTALLATION
SYSTEM REQUIREMENTS
Minimum
233MHz or Higher PentiumCompatible CPU
600MB of free hard disk space
128MB of RAM
SVGA (800 x 600 ) display
Internet Explorer (4.0 or later) or
Netscape Navigator (4.7 or later)
Local CD-ROM drive
Recommended
500MHz or Higher Pentium
Compatible CPU
128MB RAM
16bit Color
IDE
Debug IDE
Integrated editor
Interactive profiling
Multi-processor debugging
icon.
Give the name in the field with .CCXML extension then click FINISH
If any .ccxml file already exists delete it then right click on the created target SET AS DEFAULT
and click on LAUNCH SELECTED CONFIGURATION
After launching click on the CONNECT TARGET icon which is shown in above Fig. Wait some
movement it automatically opens the console window there it shows some message about the
target, memory map, pll and frequency. Now the target is ready for programming.
The above popup window will open click on CCS PROJECT then NEXT
Give the PROJECT NAME Any Name, OUTPUT TYPE EXECUTABLE, FAMILY 6000
VARIANT DSK6713, CONNECTION SPECTRUM DIGITAL ezdsp USB EMULATOR
PROJECT TEMPLATE EMPTY PROJECT (with main c) then FINISH
The above Fig shows after click of Finish, Now type your C program in the main.c workspace
If you want to add any other files to your project right click on SUM in the left side PROJECT
EXPLORER window then NEW SOURCE, HEADER, FILES
TO BUILD
PROJECT BUILD PROJECT
TO LOAD AND RUN
RUN LOAD LOAD PROGRAM BROWSE PROJECT
After clicking browse project expand the SUM DEBUG SUM. out the click OK and OK
DIFFERENCE EQUATION
An Nth order linear constant coefficient difference equation can be represented as
N
M
ak y(n-k) =
k=0
br x(n-r)
r=0
If we assume that the system is causal a linear difference equation provides an explicit
relationship between the input and output. This can be seen by rewriting above equation.
M
N
br/a0 x(n-r) --
y(n) =
r=0
ak/a0 y y(n-k)
k=1
float z[128],m[128],n[128],p[128];
main()
{
int i=0,j;
float a[3]={ 0.072231,0.144462,0.072231};
float b[3]={ 1.000000,-1.109229,0.398152};
for(i=0;i<128;i++)
{
m[i]=sin(2*3.14*FREQ*i/24000);
}
for(j=0;j<128;j++)
{
x[0]=m[j];
y[0] = (a[0] *x[0]) +(a[1]* x[1] ) +(x[2]*a[2]) - (y[1]*b[1])(y[2]*b[2]);
z[j]=y[0];
y[2]=y[1];
y[1]=y[0];
x[2]=x[1];
x[1] = x[0];
}
}
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on
Note: To verify the Diffence Equation, Observe the output for high frequency and low
frequency by
changing variable FREQ in the program
IMPULSE RESPONSE
C Program to Implement Impulse response:
#include <stdio.h>
#define Order 2
#define Len 10
float y[Len]={0,0,0},sum;
main()
{
int j,k;
float a[Order+1]={0.1311, 0.2622, 0.1311};
float b[Order+1]={1, -0.7478, 0.2722};
for(j=0;j<Len;j++)
{
sum=0;
for(k=1;k<=Order;k++)
{
if((j-k)>=0) sum=sum+(b[k]*y[jk]);
}
if(j<=Order)
{
y[j]=a[j]-sum;
}
else
{
y[j]=-sum;
}
printf("Respose[%d] = %f\n",j,y[j]);
}
}
LINEAR CONVOLUTION
To Verify Linear Convolution:
Linear Convolution Involves the follo wing operations.
1. Folding
2. Multiplication
3. Addition
4. Shifting
These operations can be represented by a Mathematical Expression as follows:
x[n] = {1, 2, 3, 4}
h[k] = {1, 2, 3, 4}
=
r=
n= 0
1
2
3
0
1
2
x[0]h[0] x[0]h[1] x[0]h[2] x[0]h[3]
x[1]h[0] x[1]h[1] x[1]h[2]
x[2]h[0] x[2]h[1]
x[3]h[0]
Output:
x[1]h[3]
x[2]h[2] x[2]h[3]
x[3]h[1] x[3]h[2]
x[3]h[3]
6
4
int x[2*LENGHT1-1]={1,2,3,4,5,6,0,0,0,0,0};
int h[2*LENGHT1-1]={1,2,3,4,0,0,0,0,0,0,0};
efficients*/
int y[LENGHT1+LENGHT2-1];
main()
{
int i=0,j;
for(i=0;i<(LENGHT1+LENGHT2-1);i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<(LENGHT1+LENGHT21);i++) printf("%d\n",y[i]);
}
PROCEDURE:
Open Code Composer Studio, make sure the DSP kit is turned on
Make the target configuration from FILE NEW TARGET CONFIG
Launch and connect the target with your pc
To make a project FILE NEW PROJECT create the project by the way which given
previously
Type the c program in the project work space and save
After creating the source file build the project
Then load the (.OUT) file
Run the program using the menu RUN RESUME
To view the graph TOOLS GRAPH SINGLE TIME and give the properties as given
blow
conv.asm:
.global _main
X
H
.half 1,2,3,4,0,0,0,0
.half 1,2,3,4,0,0,0,0
.bss
Y,14,2
;input1, M=4
;input2, N=4
;OUTPUT, R=M+N-1
.S1
.S1
.S2
.S2
.S1
.S1
MVK
.S2
X,A4
X,A4
H,B4
H,B4
Y,A5
Y,A5
7,B2
;POINTER TO X
;POINTER TO H
;POINTER TO Y
;R=M+N-1
.L1
A7
ZERO
.L1
A3
;I=0
LL2:
ZERO .L1 A2
ZERO .L1 A8
LL1:
LDH
.D1 *A4[A8],A6
MV
.S2X A8,B5
SUB
.L2 A3,B5,B7
LDH
.D2 *B4[B7],B6
NOP 4
MPY
.M1X A6,B6,A7
ADD
.L1 A8,1,A8
ADD
.L1 A2,A7,A2
CMPLT .L2X B5,A3,B0
B
.S2
LL1
NOP 5
[B0]
STH
ADD
[A2]
;J=0, for(i=0;i<m+n-1;i++)
.L1
CMPLT
B
NOP 5
B
NOP 5
.D1
A2,*A5[A3]
; for(j=0;j<=i;j++)
;
y[i]+=x[j]*h[i-j];
Circular Convolution
Steps for Cyclic Convolution
Steps for cyclic convolution are the same as the usual convolution, except all index calculations
are done "mod N" = "on the wheel"
Steps for Cyclic Convolution
Step1: Plot f[m] and h[- m]
Step 2: "Spin" h[- m] n times Anti Clock Wise (counter-clockwise) to get h[n-m] (i.e. Simply
rotate the sequence, h[n], clockwise
Step 3: Point wise multiply the f[m] wheel and the h[n- m] wheel. sum=y[n]
Step 4: Repeat for all 0=n=N- 1
Example 1: Convolve (n = 4)
{
printf(" enter the length of the first
sequence\n"); scanf("%d",&m);
printf(" enter the length of the second
sequence\n"); scanf("%d",&n);
printf(" enter the first
sequence\n"); for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" enter the second
sequence\n"); for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0)
/*If length of both sequences are not
equal*/
{
if(m>n)
zero*/
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/ a[j]=h[n-j];
/*Circular
convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
/*circular
shift*/
for(j=1;j<n
;j++)
x2[j]=
a[j-1];
x2[0]=a[n
-1];
for(i=0;i
<n;i++)
{
a[i]=x2[i];
y[k]+=x[i]*x2[i];
}
}
/*displaying the result*/
printf(" the circular convolution
is\n"); for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
IN PUT:
Eg:
OUT PUT
x[4]={3,
2, 1,0}
h[4]={1,
1, 0,0}
y[4]={3, 5, 3,0}
II.
III.
IV.
fid=fopen('FIR_lowpass_rectangular.txt','wt');
fprintf(fid,'\t\t\t\t\t\t%s\n','Cutoff -400Hz'); fprintf(fid,'\nfloat
b_rect1[31]={');
fprintf(fid,'%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n',b_rect1);
fseek(fid,-1,0);
fprintf(fid,'};');
fprintf(fid,'\n\n\n\n');
fprintf(fid,'\t\t\t\t\t\t%s\n','Cutoff -800Hz');
fprintf(fid,'\nfloat b_rect2[31]={');
fprintf(fid,'%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n',b_rect2
); fseek(fid,-1,0);
fprintf(fid,'};');
fprintf(fid,'\n\n\n\n');
fprintf(fid,'\t\t\t\t\t\t%s\n','Cutoff 1200Hz'); fprintf(fid,'\nfloat
b_rect3[31]={');
fprintf(fid,'%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n',b_rect3
); fseek(fid,-1,0);
fprintf(fid,'};');
fclose(fid);
winopen('FIR_highpass_rectangular.txt'
);
T.3 : Matlab generated Coefficients for FIR Low Pass Triangular filter
Cutoff -500Hz
float b_tri1[31]={0.000000,-0.001185,-0.003336,-0.005868,-0.007885,-0.008298,0.005988,
0.000000,0.010265,0.024895,0.043368,0.064545,0.086737,0.107877,0.125747,0.13825
5, 0.125747,0.107877,0.086737,0.064545,0.043368,0.024895,0.010265,0.000000,0.005988, -0.008298,-0.007885,-0.005868,-0.003336,-0.001185,0.000000};
Cutoff -1000Hz
float b_tri2[31]={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};
Cutoff -1500Hz
float b_tri3[31]={0.000000,-0.001104,0.001287,0.005467,0.003043,-0.007731,0.013469, 0.000000,0.023089,0.023194,-0.016737,-0.060136,0.033474,0.100508,0.282844,0.386435, 0.282844,0.100508,-0.033474,-0.060136,0.016737,0.023194,0.023089,0.000000,-0.013469, 0.007731,0.003043,0.005467,0.001287,-0.001104,0.000000};
fprintf(fid,'};');
fprintf(fid,'\n\n\n\n');
fprintf(fid,'\t\t\t\t\t\t%s\n','Cutoff -800Hz');
fprintf(fid,'\nfloat b_rect2[31]={');
fprintf(fid,'%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n',b_rect2);
fseek(fid,-1,0);
fprintf(fid,'};');
fprintf(fid,'\n\n\n\n');
fprintf(fid,'\t\t\t\t\t\t%s\n','Cutoff -1200Hz');
fprintf(fid,'\nfloat b_rect3[31]={');
fprintf(fid,'%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,\n',b_rect3);
fseek(fid,-1,0);
fprintf(fid,'};');
fclose(fid);
winopen('FIR_highpass_rectangular.txt');
-0.252386,-0.148349,-0.032134,0.045842,0.062393,0.030562,-0.013772,-0.037087,0.028043, -0.000000,0.022944,0.024725,0.007416,-0.013098,-0.020798};
Initialize Counter = 0
Initialize Output = 0 , i = 0
Output += coeff[N-i]*val[i]
Shift the input value by one
No
Is the loop
Cnt = order
Poll the ready bit, when
asserted proceed.
Yes
Output += coeff[0]*data
Put the data in val array.
fir.c
#include "filtercfg.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 };
r_output=l_output;
/* Send a sample to the left channel
*/ while (!DSK6713_AIC23_write(hCodec,
l_output));
}
signed int FIR_FILTER(float * h, signed int x)
{
int i=0;
signed long output=0;
in_buffer[0] = x;
*/
for(i=29;i>0;i--)
in_buffer[i] = in_buffer[i-1]; /* shuffle the buffer
*/
for(i=0;i<31;i++)
output = output + h[i] * in_buffer[i];
return(output);
}
PROCEDURE :
Switch on the DSP board.
Open the Code Composer Studio.
Create a new project Project New (File Name. pjt , Eg: FIR.pjt)
Right click on your project from the project viewer then NEW-OTHERSRTSC-DSP/BIOS v5.x Configuration file
Give the name as filter.tcf then select DSK6713 ti PLATFORM then finish
Now the Bios file is added in your project
Right click on the the project go to SHOW BUILT SETTING
In compiler section c6000 compiler go to INCLUDE OPTION then add the
file path of the header files which used in your program (eg
dsk6713.h,dsk6713_aic23.h)
Go to Advanced Option-PREDEFINED SYMBOL give CHIP_6713
Then go to the linker section that is C6000 linker then FILE SEARCH
PATH give the library files which are belongs to c6713
(eg:csl6713.lib,csl6713e.lib,dsk6713bsl.lib)
Now give OK
Then right click on the project BUILD
If it is build successfully then LOAD the .OUT file
Now go to DEBUG and RESUME
Add the given above C source file to the current project
Connect the speaker jack to the input of the CRO.
Observe the waveform that appears on the CRO screen.
ALGORITHM TO IMPLEMENT:
We need to realize the Butter worth band pass IIR filter by implementing the
difference equation y[n] = b0x[n] + b1x[n-1]+b2x[n-2]-a1y[n-1]-a 2y[n-2] where b0
b2, a0-a2 are feed forward and feedback word coefficients respectively
nd
[Assume 2 order of filter].These coefficients are calculated using MATLAB.A
direct form I implementation approach is taken.
Step 2 - Initialize the discrete time system , that is , specify the initial
conditions. Generally zero initial conditions are assumed.
Step 3 - Take sampled data from codec while input is fed to DSP kit from
the signal generator. Since Codec is stereo , take average of input data
read from left and right channel . Store sampled data at a memory location.
Step 5 - Output the value to codec (left channel and right channel) and
view the output at Oscilloscope.
Step 6 - Go to step 3.
Start
output = x[0]b0+x[-1]b1+
x[-2]b2 - y[-1]a1 - y[-2]a2
x[-1]=x[0]
Stop
F.1 : Flowchart for implementing IIR filter.
fid=fopen('IIR_LP_BW.txt','wt');
fprintf(fid,'\t\t----------- Pass band range: 0-2500Hz---------- \n');
fprintf(fid,'\t\t----------- Magnitude response: Monotonic----- \n\n\');
fprintf(fid,'\n float num_bw1[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',num_bw1);
fprintf(fid,'\nfloat den_bw1[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',den_bw1);
fprintf(fid,'\n\n\n\t\t----------Pass band range: 0-8000Hz
\n');
fprintf(fid,'\t\t----------- Magnitude response: Monotonic----- \n\n');
fprintf(fid,'\nfloat num_bw2[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',num_bw2);
fprintf(fid,'\nfloat den_bw2[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',den_bw2);
----------
fclose(fid);
winopen('IIR_LP_BW.txt');
fid=fopen('IIR_LP_CHEB Type1.txt','wt');
fprintf(fid,'\t\t----------- Pass band range: 2500Hz ---------- \n');
fprintf(fid,'\t\t----------- Magnitude response: Rippled (3dB) -----\n\n\');
fprintf(fid,'\nfloat num_cb1[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',num_cb1);
fprintf(fid,'\nfloat den_cb1[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',den_cb1);
fprintf(fid,'\n\n\n\t\t----------Pass band range: 8000Hz---------\n');
fprintf(fid,'\t\t----------- Magnitude response: Rippled (3dB)-----\n\n');
fprintf(fid,'\nfloat num_cb2[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',num_cb2);
fprintf(fid,'\nfloat den_cb2[9]={');
fprintf(fid,'%f,%f,%f,%f,%f,\n%f,%f,%f,%f};\n',den_cb2);
fclose(fid);
winopen('IIR_LP_CHEB Type1.txt');
%%%%%%%%%%%%%%%%%%
figure(1);
[h,w]=freqz(num_bw1,den_bw1);
w=(w/max(w))*12000;
plot(w,20*log10(abs(h)),'linewidth',2)
hold on [h,w]=freqz(num_cb1,den_cb1);
w=(w/max(w))*12000;
plot(w,20*log10(abs(h)),'linewidth',2,'color','r') grid
on
figure(2);
[h,w]=freqz(num_bw2,den_bw2);
w=(w/max(w))*12000;
plot(w,20*log10(abs(h)),'linewidth',2)
hold on [h,w]=freqz(num_cb2,den_cb2);
w=(w/max(w))*12000;
plot(w,20*log10(abs(h)),'linewidth',2,'color','r') grid
on
Fc=2500Hz
Floating Point
Values
0.044408
0.088815
0.044408
1.000000
-1.412427
0.663336
Fc=800Hz
Fixed Point
Floating Point
Fixed Point
Values(Q15)
1455
1455[B1/2]
1455
32767
-23140[A1/2]
21735
Values
0.005147
0.010295
0.005147
1.000000
-1.844881
0.873965
Values(Q15)
168
168[B1/2]
168
32767
-30225[A1/2]
28637
15
Fc=8000Hz
Floating Point
Values
0.354544
0.709088
0.354544
1.000000
0.530009
0.473218
Fixed Point
Values(Q15)
11617
11617[B1/2]
11617
32767
8683[A1/2]
15506
EdGate Technologies
Fc=2500Hz
Floating Point
Values
0.072231
0.144462
0.072231
1.000000
-1.109229
0.398152
Fixed Point
Values(Q15)
2366
2366[B1/2]
2366
32767
-18179[A1/2]
13046
Fc=800Hz
Floating Point
Values
0.009526
0.019052
0.009526
1.000000
-1.705552,
0.743655
Fixed Point
Values(Q15)
312
312[B1/2]
312
32767
-27943[A1/2]
24367
15
Fc=8000Hz
Floating Point
Values
0.465153
0.930306
0.465153
1.000000
0.620204
0.240408
Fixed Point
Values(Q15)
15241
15241[B1/2]
15241
32767
10161[A1/2]
7877
Fc=2500Hz
Floating Point
Values
0.388513
-0.777027
0.388513
1.000000
-1.118450
0.645091
Fixed Point
Values(Q15)
12730
-12730[B1/2]
12730
32767
-18324[A1/2]
21137
Fc=4000Hz
Floating Point
Values
0.282850
-0.565700
0.282850
1.000000
-0.451410
0.560534
Fixed Point
Values(Q15)
9268
-9268[B1/2]
9268
32767
-7395[A1/2]
18367
15
Fc=7000Hz
Floating Point
Values
0.117279
-0.234557
0.117279
1.000000
0.754476
0.588691
Fixed Point
Values(Q15)
3842
-3842[B1/2]
3842
32767
12360[A1/2]
19289
Fc=2500Hz
Floating Point
Values
0.626845
-1.253691
0.626845
1.000000
-1.109229
0.398152
Fixed Point
Values(Q15)
20539
-20539[B1/2]
20539
32767
-18173[A1/2]
13046
Fc=4000Hz
Floating Point
Values
0.465153
-0.930306
0.465153
1.000000
-0.620204
0.240408
Fixed Point
Values(Q15)
15241
-15241[B1/2]
15241
32767
-10161[A1/2]
7877
15
Fc=7000Hz
Floating Point
Values
0.220195
-0.440389
0.220195
1.000000
0.307566
0.188345
Fixed Point
Values(Q15)
7215
-7215[B1/2]
7215
32767
5039[A1/2}
6171
/*
* main() - Main code routine, initializes BSL and generates tone
*/
void main()
{
DSK6713_AIC23_CodecHandle hCodec;
int 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, 3);
}
signed int IIR_FILTER(const signed int * h, signed int x1)
{
static signed int x[6] = { 0, 0, 0, 0, 0, 0 }; /* x(n), x(n-1), x(n-2).
Must be static */
static signed int y[6] = { 0, 0, 0, 0, 0, 0 }; /* y(n), y(n-1), y(n-2).
Must be static */
int temp=0;
temp = (short int)x1; /* Copy input to temp */
x[0] = (signed int) temp; /* Copy input to x[stages][0] */
temp =
( (int)h[0] * x[0]) ;
/* B0 * x(n)
*/
/* B1/2 * x(n-1) */
/* B1/2 * x(n-1) */
/* B2 * x(n-2) */
/* A1/2 * y(n-1) */
/* A1/2 * y(n-1) */
/* A2 * y(n-2) */
/* y(n-2) = y(n-1) */
/* y(n-1) = y(n)
*/
x[2] = x[1];
x[1] = x[0];
/* x(n-2) = x(n-1) */
/* x(n-1) = x(n)
*/
PROCEDURE :
Switch on the DSP board.
Open the Code Composer Studio.
Create a new project Project New (File Name. pjt , Eg: FIR.pjt)
Right click on your project from the project viewer then NEW-OTHERS-RTSCDSP/BIOS v5.x Configuration file
Give the name as filter.tcf then select DSK6713 ti PLATFORM then finish
Now the Bios file is added in your project
Right click on the the project go to SHOW BUILT SETTING
In compiler section c6000 compiler go to INCLUDE OPTION then add the file path
of the header files which used in your program (eg dsk6713.h,dsk6713_aic23.h)
Go to Advanced Option-PREDEFINED SYMBOL give CHIP_6713
Then go to the linker section that is C6000 linker then FILE SEARCH PATH give
the
library
files
which
are
belongs
to
c6713
(eg:csl6713.lib,csl6713e.lib,dsk6713bsl.lib)
Now give OK
Then right click on the project BUILD
If it is build successfully then LOAD the .OUT file
Now go to DEBUG and RESUME
Adaptive Filters
#include "xyzcfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#define beta 1E-12
//rate of convergence
#define N 30
short int adaptive_filter(short int ,short int );
float delay[N];
float w[N];
//union{unsigned int uint; short channel[2];} AIC23_data;
DSK6713_AIC23_Config config = {\
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL
0x00d8, /* 2 DSK6713_AIC23_LEFTHPVOL
0x00d8, /* 3 DSK6713_AIC23_RIGHTHPVOL
0x0011, /* 4 DSK6713_AIC23_ANAPATH
0x0000, /* 5 DSK6713_AIC23_DIGPATH
0x0000, /* 6 DSK6713_AIC23_POWERDOWN
0x0043, /* 7 DSK6713_AIC23_DIGIF
0x0081, /* 8 DSK6713_AIC23_SAMPLERATE
0x0001
/* 9 DSK6713_AIC23_DIGACT
};
/*
* main() - Main code routine, initializes BSL and generates tone
*/
void main()
{
DSK6713_AIC23_CodecHandle hCodec;
int l_input, r_input; int
l_output, r_output;
}
short int adaptive_filter(short l_input1,short r_input1)
//ISR
{
short i,output,T;
float yn=0, E=0, dplusn=0, desired=0, noise=0;
for (T = 0; T < 30; T++)
{
w[T] = 0;
//init buffer for weights
delay[T] = 0;
//init buffer for delay samples
}
desired = l_input1;
noise = r_input1;
dplusn = desired + noise;
//desired+noise
delay[0] = noise;
//noise as input to adapt FIR
for (i = 0; i < N; i++)
//to calculate out of adapt FIR
yn += (w[i] * delay[i]);
//output of adaptive filter
E = (desired + noise) - yn;
//"error" signal=(d+n)-yn
for (i = N-1; i >= 0; i--)
//to update weights and delays
{
w[i] = w[i] + beta*E*delay[i]; //update weights
delay[i] = delay[i-1];
//update delay samples
}
output=((short)E);
//output=((short)dplusn);//output (desired+noise)
//overall output result
return(output);
}
PROCEDURE :
Switch on the DSP board.
Open the Code Composer Studio.
Create a new project Project New (File Name. pjt , Eg: FIR.pjt)
Right click on your project from the project viewer then NEW-OTHERS-RTSCDSP/BIOS v5.x Configuration file
Give the name as filter.tcf then select DSK6713 ti PLATFORM then finish
Now the Bios file is added in your project
Right click on the the project go to SHOW BUILT SETTING
In compiler section c6000 compiler go to INCLUDE OPTION then add the file path
of the header files which used in your program (eg dsk6713.h,dsk6713_aic23.h)
Twiddle Factor
In the Definition of the DFT, there is a factor called the Twiddle Factor
where N = number of samples.
If we take an 8 bit sample sequence we can represent the twiddle factor as a vector in
the unit circle. e.g.
Note that
1. It is periodic. (i.e. it goes round and round the circle !!)
2. That the vectors are symmetric
3. The vectors are equally spaced around the circle.
Why the FFT?
If you look at the equation for the Discrete Fourier Transform you will see that it is quite
complicated to work out as it involves many additions and multiplications involving
complex numbers. Even a simple eight sample signal would require 49 complex
multiplications and 56 complex additions to work out the DFT. At this level it is still
manageable, however a realistic signal could have 1024 samples which requires over
20,000,000 complex multiplications and additions. As you can see the number of
calculations required soon mounts up to unmanageable proportions.
The Fast Fourier Transform is a simply a method of laying out the computation, which is
much faster for large values of N, where N is the number of samples in the sequence. It
is an ingenious way of achieving rather than the DFT's clumsy P^2 timing.
The idea behind the FFT is the divide and conquer approach, to break up the original N
point sample into two (N / 2) sequences. This is because a series of smaller problems is
easier to solve than one large one. The DFT requires (N-1)^2 complex multiplications
and N(N-1) complex additions as opposed to the FFT's approach of breaking it down into
a series of 2 point samples which only require 1 multiplication and 2 additions and the
recombination of the points which is minimal.
For example Seismic Data contains hundreds of thousands of samples and would take
months to evaluate the DFT. Therefore we use the FFT.
FFT Algorithm
The FFT has a fairly easy algorithm to implement, and it is shown step by step in the
list below. Thjis version of the FFT is the Decimation in Time Method
1. Pad input sequence, of N samples, with ZERO's until the number of samples is
the nearest power of two.
e.g. 500 samples are padded to 512
(2^9) 2. Bit reverse the input sequence.
e.g. 3 = 011 goes to 110 = 6
3. Compute (N / 2) two sample DFT's from the shuffled inputs.
See "Shuffled Inputs"
4. Compute (N / 4) four sample DFT's from the two sample DFT's.
See "Shuffled Inputs"
5. Compute (N / 2) eight sample DFT's from the four sample DFT's.
See "Shuffled Inputs"
6. Until the all the samples combine into one N-sample DFT
Shuffled Inputs
The process of decimating the signal in the time domain has caused the INPUT samples
to be re-ordered. For an 8 point signal the original order of the samples is
0, 1, 2, 3, 4, 5, 6, 7
What has happened is that the bit patterns representing the sample number has been
reversed. This new sequence is the order that the samples enter the FFT.
Step 2 Generate a sine wave of frequency f (eg: 10 Hz with a sampling rate = No.
of Points of FFT(eg. 64)) using math library function.
//FFT prototype
//as input and output buffer
//intermediate buffer
//general purpose index variable
//number of new samples in
//set to 1 by ISR when iobuffer
//twiddle constants stored in w
//primary working buffer
main()
{
for (i = 0 ; i<PTS ; i++)
// set up twiddle constants in w
{
w[i].real = cos(2*PI*i/(PTS*2.0)); //Re component of twiddle
constants
w[i].imag =-sin(2*PI*i/(PTS*2.0)); //Im component of twiddle
constants
}
for (i = 0 ; i < PTS ; i++)
//swap buffers
{
iobuffer[i] = sin(2*PI*10*i/64.0);/*10- > freq,
64 -> sampling freq*/
samples[i].real=0.0;
samples[i].imag=0.0;
}
for (i = 0 ; i < PTS ; i++)
//swap buffers
{
samples[i].real=iobuffer[i]; //buffer with new data
}
for (i = 0 ; i < PTS ; i++)
samples[i].imag = 0.0;
//imag components = 0
FFT(samples,PTS);
for (i = 0 ; i < PTS ; i++)
{
x1[i] = sqrt(samples[i].real*samples[i].real
+ samples[i].imag*samples[i].imag);
}
}
//end of main
fft.c:
#define PTS 64
//# of points for FFT
typedef struct {float real,imag;} COMPLEX;
extern COMPLEX w[PTS];
//twiddle constants stored in w
void FFT(COMPLEX *Y, int N)
//input sample array, # of points
{
COMPLEX temp1,temp2;
//temporary storage variables
int i,j,k;
//loop counter variables
int upper_leg, lower_leg;
//index of upper/lower butterfly leg
int leg_diff;
//difference between upper/lower leg
int num_stages = 0;
//number of FFT stages (iterations)
int index, step;
//index/step through twiddle
constant
i = 1;
//log(base2) of N points= # of stages
do
{
num_stages +=1;
i = i*2;
}while (i!=N);
leg_diff = N/2;
//difference between upper&lower legs
step = (PTS*2)/N;
//step between values in twiddle.h
for (i = 0;i < num_stages; i++) //for N-point FFT
{
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;
(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 = 1; i < (N-1); i++)
resequencing data
{
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;
}
HOW TO PROCEED
Open Code Composer Studio, make sure the DSP kit is turned on.
Add the source files FFT256.c and FFT.C in the project using
Projectadd files to project pull down menu.
Load the program in program memory of DSP chip using the File-load program
pull down menu.
POWER SPECTRUM
The total or the average power in a signal is often not of as great an interest. We are
most often interested in the PSD or the Power Spectrum. We often want to see is how
the input power has been redistributed by the channel and in this frequency-based
redistribution of power is where most of the interesting information lies. The total area
under the Power Spectrum or PSD is equal to the total avg. power of the signal. The PSD
is an even function of frequency or in other words
To compute PSD:
The value of the auto -correlation function at zero-time equals the total power in the
signal. To compute PSD We compute the auto-correlation of the signal and then take its
FFT. The auto -correlation function and PSD are a Fourier transform pair. (Another
estimation method called period gram uses sampled FFT to compute the PSD.)
E.g.: For a process x(n) correlation is defined as:
R ( ) E { x ( n ) x ( n ) }
lim
N
1 x(n)x(n )
N n1
S ( ) F T ( R ( )) lim
R ( ) F T
( S ( ))
R()e
N 1
S()e
Step 2 Generate a sine wave of frequency f (eg: 10 Hz with a sampling rate = No.
of Points of FFT(eg. 64)) using math library function.
PSD.c:
/*************************************************************
* FILENAME
* Non_real_time_PSD.c
* DESCRIPTION
* Program to Compute Non real time PSD
* using the TMS320C6711 DSK.
***************************************************************
* DESCRIPTION
*
Number of points for FFT (PTS)
*
x --> Sine Wave Co-Efficients
*
iobuffer --> Out put of Auto Correlation.
*
x1 --> use in graph window to view PSD
/*===========================================================*/
#include <math.h>
#define PTS 128
#define PI 3.14159265358979
//FFT prototype
//as input and output buffer
//intermediate buffer
//general purpose index variable
//number of new samples in iobuffer
//set to 1 by ISR when iobuffer full
//twiddle constants stored in w
//primary working buffer
main()
{
float j,sum=0.0 ;
int n,k,i,a;
for (i = 0 ; i<PTS ; i++)
{
}
/****************Input Signal X(n)
for(i=0,j=0;i<PTS;i++)
{ x[i] = sin(2*PI*5*i/PTS);
// Signal
*************************/
x(Fs)=sin(2*pi*f*i/Fs);
samples[i].real=0.0;
samples[i].imag=0.0;
}
/********************Auto Correlation of X(n)=R(t) ***********/
for(n=0;n<PTS;n++)
{
sum=0; for(k=0;k<PTS-n;k++)
{
sum=sum+(x[k]*x[n+k]);
}
iobuffer[n] = sum;
}
/********************** FFT of R(t) ***********************/
for (i = 0 ; i < PTS ; i++)
//swap buffers
{
samples[i].real=iobuffer[i]; //buffer with new data
}
for (i = 0 ; i < PTS ; i++)
samples[i].imag = 0.0;
//imag components = 0
FFT(samples,PTS);
//end of main
FFT.c:
#define PTS 128
int leg_diff;
int num_stages = 0;
}
index += step;
}
leg_diff = leg_diff/2; step *=
2;
}
j = 0;
for (i = 1; i < (N-1); i++)
//bit reversal for resequencing data
{
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;
}
HOW TO PROCEED
Open Code Composer Studio, make sure the DSP kit is turned on.