C6713 Lab Manual
C6713 Lab Manual
LAB MANUAL
Contents
i Installing Code Composer studio V3.3……………………………………………3
5.Tone……………………………………………………………………………………………..22
9.FIR filter………………………………………………………………………………………..47
10.IIR filter……………………………………………………………………………………….50
Open 6713 DSK diagnostics utility v3.1 and conduct test, once passed
proceed the following
7. The Project View window in CCS should look as shown in Figure below.
The GEL fi le dsk6713.gel is added automatically when you create the
project. It initializes the C6713 DSK invoking the board support library to
use the PLL to set the CPU clock to 225 MHz
1. Linear Convolution
/* prg to implement linear convolution */
#include<stdio.h>
#include<math.h>
int y[20];
main()
{ int m=6; /*Lenght of i/p samples sequence*/
int n=6; /*Lenght of impulse response Co-efficients */
int i=0,j;
int x[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Input Signal Samples*/
int h[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Impulse Response
Coefficients*/
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
printf("Linear Convolution\n");
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
Results
x = {1,2,3,4,5,6}
y = {1,2,3,4,5,6}
output = conv(x,y)={
2. Circular Convolution
#include<stdio.h>
#include<math.h>
int m,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
void main()
{
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) /* Pad the smaller sequence with 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]);
}
Results
x1=[1 2 3 4];
x2=[4 3 2 1];
n = 4;
y = 24 22 24 30
#include<stdio.h>
#include<math.h>
void main()
short N = 8;
float pi = 3.1416;
int n = 0, k = 0;
sumRe = 0;
sumIm = 0;
cosine = cos(2*pi*k*n/N);
sine = sin(2*pi*k*n/N);
out_real[k] = sumRe;
out_imag[k] = sumIm;
Results
N=8
x[8] = {1,2,3,4,5,6,7,0}
+ b2 y[n-2] + ..
Example :
*/
#include<stdio.h>
float y[len]={0,0,0},sum;
main()
int j,k;
float a[order+1]={1,1,1};
equation */
float b[order+1]={1,2,1};
equation */
for(j=0;j<len;j++)
sum=0;
for(k=1;k<=order;k++)
if((j-k)>=0)
sum=sum+(b[k]*y[j-k]);
if((j)<=order)
y[j]=a[j]-sum;
else
y[j]=-sum;
printf("response[%d]=%f\n",j,y[j]);
Results
xcoeff = [1 1 1]
ycoeff = [1 2 1]
imp_resp = filter(xcoeff,ycoeff,[1 zeros(1,9)])
imp_resp = 1 -1 2 -3 4 -5 6 -7 8 -9
OUTPUT:
response[0]=1.000000
response[1]=-1.000000
response[2]=2.000000
response[3]=-3.000000
response[4]=4.000000
response[5]=-5.000000
response[6]=6.000000
response[7]=-7.000000
response[8]=8.000000
response[9]=-9.000000
5. Tone
Project Open browse
C:\CCStudio_v3.1\examples\dsk6713\bsl\tone\tone.pjt
/*
* ======== tone.c ========
*
* This example uses the AIC23 codec module of the 6713 DSK
Board Support
* Library to generate a 1KHz sine wave on the audio outputs
for 5 seconds.
* The sine wave data is pre-calculated in an array called
sinetable. The
* codec operates at 48KHz by default. Since the sine wave
table has 48
* entries per period, each pass through the inner loop takes 1
millisecond.
* 5000 passes through the inner loop takes 5 seconds.
*
* Please see the 6713 DSK help file under Software/Examples
for more
* detailed information.
*/
/*
* DSP/BIOS is configured using the DSP/BIOS configuration
tool. Settings
* for this example are stored in a configuration file called
tone.cdb. At
* compile time, Code Composer will auto-generate DSP/BIOS
related files
* based on these settings. A header file called tonecfg.h
contains the
* results of the autogeneration and must be included for
proper operation.
* The name of the file is taken from tone.cdb and adding cfg.h.
*/
#include "tonecfg.h"
/*
* The 6713 DSK Board Support Library is divided into several
modules, each
* of which has its own include file. The file dsk6713.h must be
included
/*
* main() - Main code routine, initializes BSL and generates
tone
*/
void main()
{
DSK6713_AIC23_CodecHandle hCodec;
Int16 msec, sample;
main()
{
for(i=0; i<table_size/2; i++) //set 1st half of buffer
data_table[i] = 0x7FFF; //with max value
(2^15)-1
for(i=table_size/2; i<table_size; i++) //set 2nd half of
buffer
data_table[i] = -0x8000; //with -(2^15)
i = 0; //reinit counter
comm_intr(); //init DSK, codec, McBSP
while (1); //infinite loop
}
Results
An successful execution of program the square wave is
generated as shown in figure below
7. Audio Loopback
Project Open browse
C:\CCStudio_v3.1\examples\dsk6713\csl\mcbsp\mcbsp1
/*
* ======== tsk_audio.c ========
*
* This example demonstrates the use of IOM drivers with SIOs
and tasks by
* using the DIO class driver with a user defined device mini-
driver
* called "codec" and a class driver DIO instance called
"dio_codec". This is
* the loopback application where audio is read from an input
SIO, then sent
* back via an output SIO.
#include <std.h>
#include <log.h>
#include <sys.h>
#include <mem.h>
#include <sio.h>
#ifdef _6x_
extern far LOG_Obj trace;
/*
* Buffers placed in external memory are aligned on a 128 bytes
boundary.
/* Function prototype */
static Void createStreams();
static Void prime();
/*
* ======== main ========
*/
Void main()
{
LOG_printf(&trace, "tsk_audio started");
}
/*
* ======== createStreams ========
*/
static Void createStreams()
{
SIO_Attrs attrs;
/*
* ======== prime ========
*/
static Void prime()
{
Ptr buf0, buf1, buf2, buf3;
/* Issue the first & second empty buffers to the input stream
*/
if (SIO_issue(inStream, buf0, SIO_bufsize(inStream), NULL) !=
SYS_OK) {
SYS_abort("Error issuing buffer to the input stream");
}
if (SIO_issue(inStream, buf1, SIO_bufsize(inStream), NULL) !=
SYS_OK) {
/*
* ======== echo ========
* This function copies from the input SIO to the output SIO.
You could
* easily replace the copy function with a signal processing
algorithm.
*/
Void echo()
{
Int i;
Int nmadus; /* number of minimal addressable units */
MdUns *inbuf, *outbuf;
/*
* ======== prd10secs ========
* prd10secs is configured to be called every 10 seconds
*/
Void prd10secs()
{
static Int seconds = 0;
static Int minutes = 0;
static Int hours = 0;
seconds += 10;
if (seconds == 60) {
seconds = 0;
minutes++;
if (minutes == 60) {
minutes = 0;
hours++;
}
LOG_printf(&trace, "%d hours and %d minutes", hours,
minutes);
}
else {
LOG_printf(&trace, "%d seconds", seconds);
}
}
void main()
{
short i;
{
short i;
int yn;
Results
On successful execution of program can hear scrambled voice
at lineout.
9. FIR filter.
//Fir3LP.c FIR using 3 low-pass coefficients with three different
BW
#include "lp600.cof" //coeff file LP @ 600 Hz
#include "lp1500.cof" //coeff file LP @ 1500 Hz
#include "lp3000.cof" //coeff file LP @ 3000 Hz
#include "dsk6713_aic23.h" //codec-dsk support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
short LP_number = 2; //start with 1st LP filter
int yn = 0; //initialize filter's
output
short dly[N]; //delay samples
short h[3][N]; //filter characteristics 3xN
void main()
{
short i;
for (i=0; i<N; i++)
{
dly[i] = 0; //init buffer
h[0][i] = hlp600[i]; //start addr of LP600 coeff
h[1][i] = hlp1500[i]; //start addr of LP1500
coeff
h[2][i] = hlp3000[i]; //start addr of LP3000
coeff
}
10.IIR Filter.
//IIR.c IIR filter using cascaded Direct Form II
//Coefficients a's and b's correspond to b's and a's from
MATLAB
yn=((a[i][0]*un)>>15)+((a[i][1]*dly[i][0])>>15)+((a[i][2]*dly[i][1]
)>>15);
void main()
{
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop
}
Results
On successful execution of program can hear filter sound at
lineout.