up_sampling

/*******************************************************************************
*66. Kishore kumar- kishorechurchil@gmail.com

*Name: Multi_rate.pjt

*********************************************************************************
* File Name : up_sampling.c

* Target : TMS320C6713

* Version : 3.1

* Description : This program is about up-sampling, increase of sampling frequency
low pass filter is used.
low pass filter + increase in sampling = Interpolation technique
***********************************************************************************************/

#include “dsk6713_aic23.h” //this configuration file is added for Real time analysis. It is a BIOS file
#include “sin160.h” //sine data values (calculated by Matlab)
#include “LP114.cof” //filter coefficient file (calculated by Matlab)

Uint32 fs=DSK6713_AIC23_FREQ_16KHZ; //sampling frequency

short filtmodfilt(short data);
short filter(short inp,short *dly);
short sinemod(short input);
static short filter1[N]; // array of filter to store the values
short input, output; // variable declaration

void main()
{
short i;
comm_poll();
for (i=0; i< N; i++)
{
filter1[i] = 0; //init 1st filter buffer
}
while(1)
{
input=input_sample(); //input new sample data
filtmodfilt(input); //process sample twice(upsample)
output=filtmodfilt(input); //put output into output variable
output_sample(output); //sand output to Codec output port
}
}

short filtmodfilt(short data) //filtering & modulating
{
data = sinemod(data); // modulate input sine with the generated sine wave
data = filter(data,filter1); //LP filter
return data;
}

short filter(short inp,short *dly) //implements FIR
{
short i;
int yn;
dly[N-1] = inp; //newest sample @bottom buffer
yn = dly[0] * h[N-1]; //y(0)=x(n-(N-1))*h(N-1)
for (i = 1; i >15); //filter’s output
return yn; //return y(n) at time n
}

short sinemod(short input) //sine generation/modulation
{
static short i=0;
input=(input*sine160[i++])>>11; //(input)*(sine data)
if(i>= NSINE) i = 0; //if end of sine table
return input; //return modulated signal
}

Multi-rate Filter technique

/*******************************************************************************
65.Kishore kumar- kishorechurchil@gmail.com

Name: multi_rate.pjt

*********************************************************************************

* File Name : multi_rate.c

* Target : TMS320C6713

* Version : 3.1

* Description :This Program tells about the Multi-rate Filter technique, wherer
‘Decimation’ method is used.
Decimation of sine-wave will contain: aliasing and down sampling.
load the .gel file
move the value of slider from 0 to 1.
slider = 0 = aliasing
slider = 1 = anti-aliasing
***********************************************************************************/

#include”dsk6713.h” //this file is added to initialize the DSK6713
#include “DSK6713_AIC23.h” //codec-DSK support file
#include “lp33.cof” //lowpass at 1.9 kHz

Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; // set the sampling frequency, Different sampling frequencies supported by AIC23 codec are 8, 16, 24, 32, 44.1, 48, and 96 kHz.

#define DISCARD 0
#define SAMPLE 1

short flag = DISCARD; //toggles for 2x down-sampling
short indly[N],outdly[N]; //antialias and reconst delay lines
float yn; int i; //filter output, index
short antialiasing = 1; //init for no antialiasing filter

interrupt void c_int11() // ISR call, At each Interrupt, program execution goes to the interrupt service routine
{
indly[0]=(float)(input_sample()); //new sample to antialias filter
yn = 0.0; //initialize downsampled value
if (flag == DISCARD) flag = SAMPLE; //don’t discard at next sampling
else
{
if (antialiasing == 1) //if antialiasing filter desired
{ //compute downsampled value
for (i = 0 ; i 0; i–)
indly[i] = indly[i-1]; //update input buffer

outdly[0] = (yn); //input to reconst filter 4 kHz sample values and zeros are filtered at 8 kHz rate
yn = 0.0;
for (i = 0 ; i 0; i–)
outdly[i] = outdly[i-1]; //update delays

output_sample((short)yn); //8 kHz rate sample,the value in the buffer yn indexed by the variable loop is written on to the codec.
return; // program execution goes back to while(1) and then again starts listening for next interrupt and this process goes on
}

void main()
{
comm_intr(); //init DSK, codec, McBSP, ISR function is called, using the given command
while(1); //program execution halts and it starts listening for the interrupt which occur at every sampling period Ts.
}

IIR filter plot

/*******************************************************************************
64. Kishore kumar- kishorechurchil@gmail.com

Name: IIR.pjt

*********************************************************************************

* File Name : IIR.c

* Target : TMS320C6713

* Version : 3.1

* Description :This Program tells about the IIR filter plot.Two Filters are
explained: Low-pass filter and High-pass filter.
Graph window is used to analyze the output.
***********************************************************************************/

#include “dsk6713_aic23.h” //this file is added to initialize the DSK6713
#include //lib is added to display the output on CCS window.
#include //lib is added for mathematical computation
Uint32 fs = DSK6713_AIC23_FREQ_8KHZ; // set the sampling frequency, Different sampling frequencies supported by AIC23 codec are 8, 16, 24, 32, 44.1, 48, and 96 kHz.

int i,w,wc,c,N; // variable declaration
float H[100]; // buffer declaration
float mul(float, int); // function prototype declaration
void main()
{
printf(“\n enter order of filter “); //prints the line om screen and ask the user to enter value
scanf(“%d”,&N); //scans and prints the value on CCS window
printf(“\n enter the cutoff freq “); //ask the user to enter the cut-off frequency
scanf(“%d”,&wc); //scans and prints the value on CCS window
printf(“\n enter the choice for IIR filter 1. LPF 2.HPF “); //ask the user to enter choose the Filter
scanf(“%d”,&c); //scans and prints the value on CCS window
switch(c)
{
case 1: //Low-pass filter computation
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N)); //filter co-efficients and designing calculation
printf("H[%d]=%f\n",w,H[w]); //prints the output value of Filter on CCS window
}
break;
case 2:
for(w=0;w<=100;w++) //High-pass filter computation
{
H[w]=1/sqrt(1+mul((float)wc/w,2*N)); //filter co-efficients and designing calculation
printf("H[%d]=%f\n",w,H[w]); //prints the output value of Filter on CCS window
}
break;
}
}

float mul(float a,int x) //function is called
{
for(i=0;i<x-1;i++) //takes in value of i from 0 to x-1
a*=a; //square a value
return(a); //return the value to the called function
}

FIR filter plot

/*******************************************************************************
63. Kishore kumar- kishorechurchil@gmail.com

Name: FIR.pjt

*********************************************************************************

* File Name : FIR.c

* Target : TMS320C6713

* Version : 3.1

* Description :This Program tells about the FIR filter plot.Two windowing
techniques are maintained: Rectangular and Triangular Window.
Graph window is used to analyze the output.
***********************************************************************************/

#include “dsk6713_aic23.h” //this file is added to initialize the DSK6713
#include //lib is added to display the output on CCS window.

#define pi 3.1415 //variable declaration

Uint32 fs = DSK6713_AIC23_FREQ_8KHZ; // set the sampling frequency, Different sampling frequencies supported by AIC23 codec are 8, 16, 24, 32, 44.1, 48, and 96 kHz.
int n,N,c; // variable declaration
float wr[64],wt[64]; // buffer declaration

void main()
{
printf(“\n enter no. of samples,N= :”); //prints the line om screen and ask the user to enter value
scanf(“%d”,&N); //scans and prints the value on CCS window
printf(“\n enter choice of window function\n 1.rect \n 2. triang \n c= :”); //ask the user to enter choose the technique
scanf(“%d”,&c); //scans and prints on window
printf(“\n elements of window function are:”); //prints on CCS window
switch(c)
{
case 1: //Selects Rectangular windowing technique
for(n=0;n<=N-1;n++) //takes in value of n from 0 to N-1
{
wr[n]=1; //makes all co-efficients value to be 'one'
printf(" \n wr[%d]=%f",n,wr[n]); //prints the value of filter co-efficients on CCS window
}
break; //get out off the case1
case 2:
for(n=0;n<=N-1;n++) //takes in value of n from 0 to N-1
{
wt[n]=1-(2*(float)n/(N-1)); //calculate the co-effiecients value by computing acc. to formula
printf("\n wt[%d]=%f",n,wt[n]); //prints the value of filter co-efficients on CCS window
}
break; //get out off the case2
}
}

periodogram_program

/*******************************************************************************
62. Kishore kumar- kishorechurchil@gmail.com

Name: periodogram_program.pjt

*********************************************************************************

* File Name : periodogram.c

* Target : TMS320C6713

* Version : 3.1

*Purpose ; This example program explains you to design Periodogram of any signal.
there are three steps to perform Periodogram.
connect Function-Generator to the Line-in of the DSK.
1. Take input as a sine wave (or choose any signal)
2. Add noise to the signal
3. Take autocorrelation of Sine wave
4. Take FFT of autocorrelated signal
5. Applying the formula for periodogram on the FFT output
4. draw the input, periodogram and FFT of the input signal.
A folder is attached showing the process, how to analyse the output.
*************************************************************************************/

#include”dsk6713_aic23.h” //dsk6713 support file
#include”dsk6713.h”
#include //for input & output measurement
#include //for mathematical operations
#include

#define BUFSIZE 128 //# of points for FFT
#define PI 3.14159265358979 //variable declaration
#define FFT_POINTS 1024
#define M_MAX 64
#define window 1
#define N_MAX 256
#define VARIANCE 1.0

typedef struct {float real,imag;} COMPLEX;
COMPLEX w[BUFSIZE];
void FFT(COMPLEX *Y, int n); //FFT prototype
void spectrum(float *r,short M); //spectrum prototype

int flag = 0; //set to 1 by ISR when iobuffer full
float y[128];
COMPLEX w[BUFSIZE]; //twiddle constants stored in w
COMPLEX samples[BUFSIZE];
typedef Int sample; // representation of a data sample

sample inp_buffer[BUFSIZE];
int out_buffer[BUFSIZE];
short bufferlength =10000;
int gain=1;

DSK6713_AIC23_Config config = { // DSK settings
0×0017, // 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume
0×0017, // 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
0×0011, // 4 DSK6713_AIC23_ANAPATH Analog audio path control
0×0000, // 5 DSK6713_AIC23_DIGPATH Digital audio path control
0×0000, // 6 DSK6713_AIC23_POWERDOWN Power down control
0×0043, // 7 DSK6713_AIC23_DIGIF Digital audio interface format
0×0001, // 8 DSK6713_AIC23_SAMPLERATE Sample rate control
0×0001 // 9 DSK6713_AIC23_DIGACT Digital interface activation
};

int *input = inp_buffer; // inp_buffer data is stored into a variable of pointer type
int *output =out_buffer;
Uns size = BUFSIZE;
int out_buffer1[BUFSIZE];
int out_buffer2[BUFSIZE];

int out_buffer3[BUFSIZE];
int buffercount=0;
int m=0,t,u,x1[BUFSIZE];
float sum=0.0 ;
int i=0,s=0, j,n,k, t=0;
int out[BUFSIZE];

float P[2*FFT_POINTS];
float X[N_MAX];

void noise_add(float* x,short const N);

Uint32 l_output,l_input,r_input,r_output; // variables to access the CODEC ports

void main()
{
short N=128;
for (i = 0 ; i<BUFSIZE ; i++) // set up twiddle constants in w
{
w[i].real = cos(2*PI*i/(BUFSIZE*2.0)); //Re component of twiddle constants
w[i].imag =-sin(2*PI*i/(BUFSIZE*2.0)); //Im component of twiddle constants
}

while(size–)
{
signal_generate(); //function-call for signal generation and the interrupt goes to the function
noise_add(X,N); //function-call for noise addition and the interrupt goes to the function
autocorrelation(); //function-call for auto-corretaion and the interrupt goes to the function
FFT(samples,BUFSIZE); //call function FFT
Periodogram(); //function-call for periodogram and the interrupt goes to the function
}
}

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; //indexof 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
printf("\nFast Fourier Transform of obtained signal\n");
do
{
num_stages +=1;
i = i*2;
}
while (i!=N);
leg_diff = N/2; //difference between upper&lower legs
step = (BUFSIZE*2)/N; //step between values in twiddle.h// 512
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;

/******bit reversal for resequencing data***********/
printf("\n Bit-reversal is done \n");
for (i = 1; i < (N-1); i++)
{
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; //return the value to the function called
}

signal_generate() //signal generation using the CODEC 'function-generator'
{
DSK6713_AIC23_CodecHandle hCodec; // initialize the Codec
DSK6713_init();
hCodec = DSK6713_AIC23_openCodec(0, &config);
DSK6713_AIC23_setFreq(hCodec,2); // Set the codec sample rate frequency

printf("\nInput Signal fom Function Generator\n");
for(s=0;s<BUFSIZE;s++)
{
while (!DSK6713_AIC23_read(hCodec, &l_input)); // Read a sample to the left channel
while (!DSK6713_AIC23_read(hCodec, &r_input)); // Read a sample to the right channel
out_buffer[s] =(int)((short) l_input* gain);
r_input=l_input;
}
return; //return to the function, from where called.
}

void noise_add(float *x, short const N) //noise is added in the input signal
{
int i,R,theta;
printf("\n Noise(Random signal) is added into the input-signal\n");
for(i=0;i<N;i++)
{
R = (float)rand()/(float)(RAND_MAX);
R = sqrt(-2.0*VARIANCE*log(1-R));
theta = 2.0*PI*(float)rand()/(float)(RAND_MAX);
out_buffer1[i] = out_buffer[i] + R*cos(theta);
}
}

autocorrelation() //auto-correlation of the input_signal and noise
{
printf("\nAuto-Correlation is calculated of the (Input signal + Noise)\n");
for(n=0;n<BUFSIZE;n++)
{
sum=0;
for(k=0;k<BUFSIZE-n;k++)
{
sum= sum+(out_buffer[k]*out_buffer[n+k]); // Auto Correlation R(t)
out[n] =( sum);
}
}

for (i = 0 ; i < BUFSIZE ; i++) //swap buffers
{
samples[i].real=out[i]; //buffer with new data
}
for (i = 0 ; i <BUFSIZE ; i++)
{
samples[i].imag = 0.0;
}
return; //return the value to the function called.
}

Periodogram() // periodogram calculation is being done here
{
printf("\n Periodogram of the Signal \n"); //prints the line on CCS Window
for (i = 0 ; i < BUFSIZE ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real + samples[i].imag*samples[i].imag)/16; //formula for the computation of Periodogram

}
size = BUFSIZE;
input = inp_buffer;
output = out_buffer;
l_output = (int)((short)output);
r_output = l_output;
return; //return the value to the function called
}

Analysis of input and output

/*******************************************************************************
61. Kishore kumar- kishorechurchil@gmail.com

Name: input-output.pjt

*********************************************************************************

* File Name : input-output.c

* Target : TMS320C6713

* Version : 3.1

* Description :This Program tells about the usage of CODEC and analyses of input and output.
Function-generator is connected to the Line-in of Codec and output is analysed
on RTDX channel.Matlab loads the program in ccs and displays the output on RTDX.
**********************************************************************************************/

#include”configuration1cfg.h” //this configuration file is added for Real time analysis. It is a BIOS file
#include”dsk6713.h” //this file is added to initialize the DSK6713
#include”dsk6713_aic23.h” //codec-DSK support file
#include // RTDX support file
#define BUFSIZE 64 //define the buffer-size
#define BUFFERLENGTH 64 //define the bufferlength

typedef Int sample;
int out_buffer[64]; //output buffer
int *output = out_buffer;
Uns size = BUFSIZE;
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ; //set sampling rate

/* main() – Main code routine */
DSK6713_AIC23_CodecHandle hCodec;
Uint32 l_input, r_input;
int j=0,i=0,loop=0 ;

RTDX_CreateOutputChannel(ochan); //create out channel for C6x–>PC data transfer

DSK6713_AIC23_Config config = {\
0×0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline input channel volume */\
0×0017, /* 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 */\
0×0012, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */\
0×0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */\
0×0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */\
0×0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */\
0×0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */\
0×0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};

void main()
{
DSK6713_AIC23_CodecHandle hCodec; //initialize the Codec

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

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

DSK6713_AIC23_setFreq(hCodec, 2); // set frequency

IRQ_globalEnable(); //enable global interrupt-RTDX is interrupt-driven
IRQ_nmiEnable(); //enable NMI interrupt

while(!RTDX_isOutputEnabled(&ochan)) //wait for PC to enable RTDX
puts(“\n\n Waiting… “); //while waiting

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

out_buffer[i]= l_input;
i++;
if (i== BUFFERLENGTH)
i=0;
if (++loop >7)
loop = 0;
RTDX_write(&ochan,out_buffer,sizeof(out_buffer)); //send 256 samples DSK–>PC
}

}

triangular matlab

/*******************************************************************************
Kishore kumar- kishorechurchil@gmail.com

Name: triangularmatlab.pjt

*********************************************************************************

* File Name : triangularmatlab.c

* Target : TMS320C6713

* Version : 3.1

* Description :This Program tells about the rtdx_matlabFFT.c RTDX-MATLAB
for data transfer from PC->DSK (with loop) and display a Triangular-wave.
**********************************************************************************************/

#include”configuration2cfg.h” //this configuration file is added for Real time analysis. It is a BIOS file
#include”dsk6713.h” //this file is added to initialize the DSK6713
#include”dsk6713_aic23.h” //codec-DSK support file
#include // RTDX support file
#define BUFSIZE 64
#define BUFFERLENGTH 64
#define TABLE_SIZE 24

typedef Int sample;
sample inp_buffer[BUFSIZE]; // Global declarations
int trang_buffer[BUFFERLENGTH];
int out_buffer[64]; //output buffer
int loop=0,i=0,m=0,l=0;
sample *input = inp_buffer;
Uns size = BUFSIZE;

int trang_table[TABLE_SIZE]=
{
0,2000,4000,6000,8000,10000,12000,10000,8000,6000,
4000,2000,0,-2000,-4000,-6000,-8000,-10000,-12000,-10000,
-8000,-6000,-4000,-2000
}; //table values

Uint32 fs=DSK6713_AIC23_FREQ_16KHZ; //set sampling rate

RTDX_CreateOutputChannel(ochan); //create out channel for C6x–>PC data transfer

DSK6713_AIC23_Config config = {\
0×0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline input channel volume */\
0×0017, /* 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 */\
0×0012, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */\
0×0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */\
0×0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */\
0×0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */\
0×0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */\
0×0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};

void main()
{
DSK6713_AIC23_CodecHandle hCodec;

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

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

DSK6713_AIC23_setFreq(hCodec, 2); // set frequency

IRQ_globalEnable(); //enable global interrupt-RTDX is interrupt-driven
IRQ_nmiEnable(); //enable NMI interrupt

while(!RTDX_isOutputEnabled(&ochan)) //wait for PC to enable RTDX
puts(“\n\n Waiting… “); //while waiting

while(1)
{
for(m=0;m 23)
m = 0;
}
out_buffer[i] = trang_table[l]; //output to buffer
RTDX_write(&ochan,out_buffer,sizeof(out_buffer)); //send 256 samples DSK–>PC
}

}

square matlab

/*******************************************************************************
60. Kishore kumar- kishorechurchil@gmail.com

Name: squarematlab.pjt

*********************************************************************************

* File Name : squarematlab.c

* Target : TMS320C6713

* Version : 3.1

* Description :This Program tells about the rtdx_matlabFFT.c RTDX-MATLAB
for data transfer from PC->DSK (with loop) and display a Square-wave.
**********************************************************************************************/

#include”configuration1cfg.h” //this configuration file is added for Real time analysis. It is a BIOS file
#include”dsk6713.h” //this file is added to initialize the DSK6713
#include”dsk6713_aic23.h” //codec-DSK support file
#include // RTDX support file
#define BUFSIZE 64
#define BUFFERLENGTH 64
#define table_size 8

typedef Int sample;
sample inp_buffer[BUFSIZE]; // Global declarations
sample out_buffer[BUFFERLENGTH];
int data_table[table_size]; //data table array

sample *input = inp_buffer;
Uns size = BUFSIZE;
int i=0,j=0;

Uint32 fs=DSK6713_AIC23_FREQ_16KHZ; //set sampling rate

RTDX_CreateOutputChannel(ochan); //create out channel for C6x–>PC data transfer

DSK6713_AIC23_Config config = {\
0×0017, /* 0 DSK6713_AIC23_LEFTINVOL Leftline input channel volume */\
0×0017, /* 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 */\
0×0012, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */\
0×0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */\
0×0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */\
0×0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */\
0×0081, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */\
0×0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};

void main()
{
DSK6713_AIC23_CodecHandle hCodec;

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

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

DSK6713_AIC23_setFreq(hCodec, 2); // set frequency

IRQ_globalEnable(); //enable global interrupt-RTDX is interrupt-driven
IRQ_nmiEnable(); //enable NMI interrupt

while(!RTDX_isOutputEnabled(&ochan)) //wait for PC to enable RTDX
puts(“\n\n Waiting… “); //while waiting

while(1)
{
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] = -0×8000; //with -(2^15)
}
i = 0;

for(i=0; i<table_size/2; i++)
{
out_buffer[j] = 0.01*data_table[i]; //output to buffer
j++;
if(j==BUFFERLENGTH) j=0;
}
for(i=table_size/2;i

PC
}

}

programme generate sinusoidal signal sampled

/*******************************************************************************
59.Kishore kumar- kishorechurchil@gmail.com

Name: rtdxpcm.pjt

*********************************************************************************

* File Name : rtdxpcm.c

* Target : TMS320C6713

* Version : 3.1

* Description : pcm.c programme generate sinusoidal signal sampled the signal
and the quantized the signal out_buffer range= 256
sampled_data buffer range=256
quan_data buffer range= 256
**********************************************************************************************/

#include //for input & output measurement
#include”rtdxpcmcfg.h” //this configuration file is added for Real time analysis. It is a BIOS file
#include “dsk6713_aic23.h” //for dsk_6713 support file
#include “dsk6713.h”
#include //for rtdx support
#include “target.h” //for init interrupt

#define table_size 256 //size of table=160
#define BUFSIZE 64
#define BUFFERLENGTH 256
typedef Int sample; // representation of a data sample from A2D
sample inp_buffer[BUFSIZE]; // Global declarations
sample out_buffer[BUFFERLENGTH];
Int volume=0; // = MINVOLUME; the scaling factor for volume control

// RTDX channels
RTDX_CreateInputChannel(control_channel); // create contol channel
RTDX_CreateInputChannel(A2D_channel); // create input channel
RTDX_CreateOutputChannel(D2A1_channel); // create output channel1
RTDX_CreateOutputChannel(D2A2_channel); // create output channel2
RTDX_CreateOutputChannel(D2A3_channel); // create output channel3

Uint32 fs = DSK6713_AIC23_FREQ_48KHZ; //set sampling rate
int sampled_data[table_size]; //data table array
int quan_data[256];
int quant_data[256];
int out_buffer[256];
int sam_data[256];
sample *input = inp_buffer;
Uns size = BUFSIZE;
int i=0,j=0,k=0,l=0,m=0,loop=0;

/* Pre-generated sine wave data, 16-bit signed samples */
int sine_table[40] =
{ 0, 1736, 3420, 5000, 6427, 7660, 8660, 9396, 9848, 9961, 10000, 9961,
9848, 9396, 8660, 7660, 6427, 5000, 3420, 1736, 0, -1736, -3420,-5000,
-6427,-7660, -8660,-9396, -9848, -9961,-10000, -9961, -9848,-9396, -8660,-7660,
-6427,-5000, -3420,-1736};

void main()
{
TARGET_INITIALIZE(); // Enable RTDX interrupt
RTDX_enableInput(&control_channel); // enable volume control input channel

while (TRUE)
{
puts(“Pulse Code Modulation Example Started”);
if (!RTDX_channelBusy(&control_channel)) // Read a new volume when the hosts send it
{
RTDX_readNB(&control_channel, &volume, sizeof(volume));
}

while (!RTDX_isInputEnabled(&A2D_channel)) // checks if Input channel (A2D) of RTDX channel is not enabled
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for input*/
#endif
}
/*
* A2D: get digitized input (get signal from the host through RTDX).
* If A2D_channel is enabled, read data from the host.
*/
RTDX_read(&A2D_channel, input, size*sizeof(sample)); // read data by DSK

out_buffer[j] = sine_table[loop]; //output to buffer
j++; //increment buffer count
if(j==BUFFERLENGTH) j=0; //if @ bottom reinit count
if (++loop >= 40)
loop = 0; //check for end of table

RTDX_write(&D2A1_channel,out_buffer, size*sizeof(sample)); /* store the Sinewave in out_buffer to display on the graph*/

while(RTDX_writing)
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}

for(i=0; i<=2; i++)
sampled_data[i] = 0;
for(i=2; i<=4; i++)
sampled_data[i] = 0x3fff;
for(i=4; i<=6; i++)
sampled_data[i] = 0;
for(i=6; i<=8; i++)
sampled_data[i] = 0x6ed8;
for(i=8; i<=10; i++)
sampled_data[i] = 0;
for(i=10; i<=12; i++)
sampled_data[i] = 0x7ffd;
for(i=12; i<=14; i++)
sampled_data[i] = 0;
for(i=14; i<=16; i++)
sampled_data[i] = 0x6ed8;
for(i=16; i<=18; i++)
sampled_data[i] = 0;
for(i=18; i<=20; i++)
sampled_data[i] = 0x3fff;
for(i=20; i<=22; i++)
sampled_data[i] = 0;
for(i=22; i<=24; i++)
sampled_data[i] = -0x3fff;
for(i=24; i<=26; i++)
sampled_data[i] = 0;
for(i=26; i<=28; i++)
sampled_data[i] = -0x6ed8;
for(i=28; i<=30; i++)
sampled_data[i] = 0;
for(i=30; i<=32; i++)
sampled_data[i] = -0x7ffd;
for(i=32; i<=34; i++)
sampled_data[i] = 0;
for(i=34; i<=36; i++)
sampled_data[i] = -0x6ed8;
for(i=36; i<=38; i++)
sampled_data[i] = 0;
for(i=38; i<=40; i++)
sampled_data[i] = -0x3fff;
for(i=40; i<=42; i++)
sampled_data[i] = 0;

for(i=0; i<=2; i++)
{
sam_data[l] =sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=2; i<=4; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=4; i<=6; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=6; i<=8; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=8; i<=10; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=10; i<=12; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=12; i<=14; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=14; i<=16; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=16; i<=18; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=18; i<=20; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=20; i<=22; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}

for(i=22; i<=24; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=24; i<=26; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=26; i<=28; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=28; i<=30; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=30; i<=32; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=32; i<=34; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=34; i<=36; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=36; i<=38; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=38; i<=40; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}
for(i=40; i<=42; i++)
{
sam_data[l] = sampled_data[i];
l++;
if(l==BUFFERLENGTH) l=0; //if @ bottom reinit count
}

/* store the sampled signal into quant_data */
RTDX_write(&D2A2_channel,sam_data, size*sizeof(sample)); // sends the sam_data value on outputchannel2 (D2A2) of the RTDX

while(RTDX_writing)
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}

for(i=0; i<=2; i++)
quan_data[i] = 0;
for(i=2; i<=6; i++)
quan_data[i] = 0x3fff;
for(i=6; i<=10; i++)
quan_data[i] = 0x6ed8;
for(i=10; i<=14; i++)
quan_data[i] = 0x7ffd;
for(i=14; i<=18; i++)
quan_data[i] = 0x6ed8;
for(i=18; i<=22; i++)
quan_data[i] = 0x3fff;
for(i=22; i<=26; i++)
quan_data[i] = -0x3fff;
for(i=26; i<=30; i++)
quan_data[i] = -0x6ed8;
for(i=30; i<=34; i++)
quan_data[i] = -0x7ffd;
for(i=34; i<=38; i++)
quan_data[i] = -0x6ed8;
for(i=38; i<=42; i++)
quan_data[i] = -0x3fff;
for(i=42; i<=46; i++)
quan_data[i] = 0;

for(i=0; i<=2; i++)
{
quant_data[m] =quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=2; i<=6; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=6; i<=10; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=10; i<=14; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=14; i<=18; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=18; i<=22; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=22; i<=26; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=26; i<=30; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=30; i<=34; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=34; i<=38; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=38; i<=42; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
for(i=42; i<=46; i++)
{
quant_data[m] = quan_data[i];
m++;
if(m==BUFFERLENGTH) m=0; //if @ bottom reinit count
}
/* store the Quantized signal into quant_data */
RTDX_write(&D2A3_channel,quant_data, size*sizeof(sample)); // sends the quant_data value on outputchannel3 (D2A3) of the RTDX

while(RTDX_writing)
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}

} // end of while-loop

} // end od Main program

Delta Modulation(by sine wave)

/*******************************************************************************
58.Kishore kumar- kishorechurchil@gmail.com

Name: RTDX_FFT2
*********************************************************************************
* File Name : fft2.c

* Target : TMS320C6713

* Version : 3.1

*Purpose ; DSP program generate the Delta Modulation by genrating the sine
wave sampled it and coded it by comparing the sinewave with sampled or
approximated wave and produces an output stream.Output datas are sent to host
files using 3 RTDX channels.Interface CCstudio with VB and display the all three
wave (sine wave sampledwave and Deltqa modulated wave) on VB graph screen.
dm.c programme generate the signal then sampled the signal and coded the signal
out_buffer range= 56 sampled_data buffer range= 56 dm_data buffer range=56///57out_buffer
*************************************************************************************/

#include //for input & output measurement
#include”rtdxdmcfg.h” //this configuration file is added for Real time analysis. It is a BIOS file
#include //for rtdx support
#include “target.h” //for init interrupt

#define table_size 56 //# of points for tablesize
#define SIZE 26
#define BUFFERSIZE 256 //# of points for buffersize
#define BUFSIZE 64
#define BUFFERLENGTH 256

typedef Int sample; /* representation of a data sample from A2D */

/* Global declarations */
sample inp_buffer[BUFSIZE];
sample out_buffer[BUFFERLENGTH];

Int volume=0; // = MINVOLUME; /* the scaling factor for volume control */

/* RTDX channels */
RTDX_CreateInputChannel(control_channel); // create contol channel
RTDX_CreateInputChannel(A2D_channel); // create input channel
RTDX_CreateOutputChannel(D2A1_channel); // create output channel1
RTDX_CreateOutputChannel(D2A2_channel); // create output channel2

// Global declaration
int modulating_data[57];
int modulating_signal[256];
int sampled_data[table_size]; //data table array
int sampled_signal[256];
int dm_data[256];
int dm_signal[256];
int i=0,j=0,k=0; //variable declaration
int a=0,m=0,l=0,b=0;
int const BUFLENGTH = 57;
sample *input = inp_buffer; // inp_buffer data is stored into a variable of pointer type
Uns size = BUFSIZE;

/* Pre-generated sine wave data, 16-bit signed samples */

int sine_table[15] =
{ 3420, 5000, 6427, 7660, 8660, 9396, 9848, 10000,
9848, 9396, 8660, 7660, 6427, 5000, 3420};

void main()
{
TARGET_INITIALIZE(); // Enable RTDX interrupt
RTDX_enableInput(&control_channel); // enable volume control input channel
while (TRUE)
{
puts(“Delta Modulation Example Started\n”); //prints the line on CCS window if the condition is true
if (!RTDX_channelBusy(&control_channel)) // Read a new volume when the hosts send it
{
RTDX_readNB(&control_channel, &volume, sizeof(volume));
}
while (!RTDX_isInputEnabled(&A2D_channel)) // checks if Input channel (A2D) of RTDX channel is not enabled
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); // poll comm channel for input
#endif
}

/*
* A2D: get digitized input (get signal from the host through RTDX).
* If A2D_channel is enabled, read data from the host.
*/
RTDX_read(&A2D_channel, input, size*sizeof(sample)); // read data by DSK

/* generate the modulating signal */
for(j=0; j < SIZE; j++)
modulating_data[j] = 1736; //output to buffer
if(j == 26)
{
for(k=0; k<=14;k++)
{
modulating_data[j] = sine_table[k] ; //output to buffer
j++;
}
}
if(j==41)
{
for(j=41; j <=56 ; j++)
modulating_data[j] = 1736;
}
if (j== BUFLENGTH)
j=0;

/*display the modulating signal on CCS graph*/

for(j=0;j<57;j++)
{
modulating_signal[l]=modulating_data[j];
l++;
if (l == BUFFERSIZE)
l=0;
}

RTDX_write(&D2A1_channel,modulating_signal, size*sizeof(sample)); // sends the modulating_signal value on outputchannel1 (D2A1) of the RTDX

while(RTDX_writing)
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}

/* sampled the signal */
for(i=0; i<=4; i++)
sampled_data[i] = 200;
for(i=4; i<=8; i++)
sampled_data[i] = 1000;
for(i=8; i<=12; i++)
sampled_data[i] = 1800;
for(i=12; i<=16; i++)
sampled_data[i] = 1000;
for(i=16; i<=20; i++)
sampled_data[i] = 1800;
for(i=20; i<=27; i++)
sampled_data[i] = 1000;
for(i=27; i<=29; i++)
sampled_data[i] = 4900;
for(i=29; i<=31; i++)
sampled_data[i] = 9400;
for(i=31; i<=35; i++)
sampled_data[i] = 8000;
for(i=35; i<=38; i++)
sampled_data[i] = 9000;
for(i=38; i<=40; i++)
sampled_data[i] = 7800;
for(i=40; i<=42; i++)
sampled_data[i] = 5500;
for(i=42; i<=44; i++)
sampled_data[i] =1000;
for(i=44; i<=47; i++)
sampled_data[i] = 3000;
for(i=47; i<=50; i++)
sampled_data[i] = 1000;
for(i=50; i<=53; i++)
sampled_data[i] = 3000;
for(i=53; i<=56; i++)
sampled_data[i] = 1000;

/*display the sampled signal*/

for(i=0;i<57;i++)
{
sampled_signal[m]=sampled_data[i];
m++;
if (m == BUFFERSIZE)
m=0;
}

RTDX_write(&D2A2_channel,sampled_signal, size*sizeof(sample)); // sends the sampled_signal value on outputchannel2 (D2A2) of the RTDX

while(RTDX_writing)
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}

/* generate delta modulated signal*/

for(i=0 ;i<table_size;i++)
{
if(out_buffer[j]< sampled_data[i])
{
dm_data[a]=0;
a++;
if (a== BUFLENGTH) a=0;
}
else
{
dm_data[a]=0x7FFF;
a++;
if (a== BUFLENGTH) a=0;
}
j++;
}
i=0;
}
}

April 2014
M T W T F S S
« Nov    
 123456
78910111213
14151617181920
21222324252627
282930