Program-5: Jai Kumar Soni
Program-5: Jai Kumar Soni
Aim:-
To generate sinusoidal signal using DSK-6713 processor.
Coding:-
/* DSP program generate the sine wave using lookup table */
/* and produces an output stream. Output data are sent to host files */
/* using RTDX channels. Interface CCstudio with VB and display */
/* the wave on VB graph screen */
/***************************************************************************/
#include <std.h>
#include <log.h>
#include <rtdx.h>
#include "rtdxsinecfg.h"
#include "target.h"
#define BUFSIZE 64
#define BUFFERLENGTH 64
#define MINVOLUME 1
/* Global declarations */
sample inp_buffer[BUFSIZE];
int out_buffer[BUFFERLENGTH];
Int volume=0;
/* RTDX channels */
RTDX_CreateInputChannel(control_channel);
RTDX_CreateInputChannel(A2D_channel);
RTDX_CreateOutputChannel(D2A1_channel);
RTDX_enableInput(&control_channel);
while (TRUE)
{
/* Read a new volume when the hosts send it */
if (!RTDX_channelBusy(&control_channel)) {
RTDX_readNB(&control_channel, &volume, sizeof(volume));
}
while (!RTDX_isInputEnabled(&A2D_channel)){
#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));
/*
* D2A: produce analog output (send signal to the host through RTDX).
* If D2A_channel is enabled, write data to the host.
*/
out_buffer[i]= sin_table[loop];
RTDX_write(&D2A1_channel,out_buffer, size*sizeof(sample));
while(RTDX_writing)
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}
}
}
Output :-
Aim:-
To generate square wave signal using DSK-6713 processor.
Coding:-
/* DSP program generate the Square wave using lookup table */
/* and produces an output stream. Output data are sent to host files */
/* using RTDX channels. Interface CCstudio with VB and display */
/* the wave on VB graph screen through RTDX channel */
/***************************************************************************/
#include <std.h>
#include "rtdxsqurecfg.h"
#include "dsk6713_aic23.h"
#include "dsk6713.h"
#include <log.h>
#include <rtdx.h>
#include "target.h"
#define BUFSIZE 64
#define BUFFERLENGTH 64
#define table_size 8 //size of table=48
/* Global declarations */
sample inp_buffer[BUFSIZE];
sample out_buffer[BUFFERLENGTH];
Int volume=0;
/* RTDX channels */
RTDX_CreateInputChannel(control_channel);
RTDX_CreateInputChannel(A2D_channel);
RTDX_CreateOutputChannel(D2A1_channel);
/*
* ======== main ========
*/
Void main()
{
while (TRUE)
{
while (!RTDX_isInputEnabled(&A2D_channel)){
#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));
/*
* D2A: produce analog output (send signal to the host through RTDX).
* If D2A_channel is enabled, write data to the host.
*/
RTDX_write(&D2A1_channel,out_buffer, size*sizeof(sample));
printf("hello");
while(RTDX_writing){
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}
}
}
Aim:-
To generate triangular wave signal using DSK-6713 processor.
Coding:-
/* DSP program generate the Triangular wave using lookup table */
/* and produces an output stream. Output data are sent to host files */
/* using RTDX channels. Interface CCstudio with VB and display */
/* the wave on VB graph screen through RTDX channel */
/***************************************************************************/
#include <std.h>
#include"rtdxtrangcfg.h"
#include "dsk6713_aic23.h"
#include "dsk6713.h"
#include <log.h>
#include <rtdx.h>
#include "target.h"
#define BUFSIZE 64
#define BUFFERLENGTH 64
/* Global declarations */
sample inp_buffer[BUFSIZE];
Int volume=0;
// = MINVOLUME; /* the scaling factor for volume control */
int out_buffer[256];
int loop=0;
int i=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
int out_buffer[256]; //output buffer
void main()
{
while (TRUE)
{
while (!RTDX_isInputEnabled(&A2D_channel)){
#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));
RTDX_write(&D2A1_channel,out_buffer, size*sizeof(sample));
printf("hello");
while(RTDX_writing)
{
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}
}
}
Output :-
Aim:-
To perform linear convolution using DSK-6713 processor.
Coding:-
#include<stdio.h>
#include "linearcfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#include "rtdx.h"
#include "target.h"
#define BUFSIZE 7
/* RTDX channels */
RTDX_CreateInputChannel(control_channel);
RTDX_CreateInputChannel(A2D_channel);
RTDX_CreateOutputChannel(D2A1_channel);
RTDX_CreateOutputChannel(D2A2_channel);
int out_buffer[10];
void main()
{
DSK6713_AIC23_CodecHandle hCodec;
//Int16 msec;
while (TRUE) {
/* Read a new volume when the hosts send it */
if (!RTDX_channelBusy(&control_channel)) {
RTDX_readNB(&control_channel, &volume, sizeof(volume));
}
while (!RTDX_isInputEnabled(&A2D_channel)){
#if RTDX_POLLING_IMPLEMENTATION
/*
* 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));
/*
* Vector Scale: Scale the input signal by the volume factor to
* produce the output signal*/
while(size--)
for(i=0;i<m+n-1;i++)
{
out_buffer[i]=0;
for(j=0;j<=i;j++)
out_buffer[i]+=x[j]*h[i-j];
}
// for(i=0;i<m+n-1;i++)
// printf("%d\n",out_buffer[i]);
size = BUFSIZE;
input = inp_buffer;
output = out_buffer;
/*
* D2A: produce analog output (send signal to the host through RTDX).
* If D2A_channel is enabled, write data to the host.
*/
RTDX_write(&D2A1_channel,out_buffer, size*sizeof(sample));
while(RTDX_writing){
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
Output :-
Aim:-
To design an FIR filter using DSK-6713 processor.
Coding:-
*Purpose ; This program explains FIR Filter. input is internally generated noise.The band
pass filter we designed is of the order 41.
*****************************************************************************
********************/
#include"fircfg.h"
#include"dsk6713.h"
#include "dsk6713_aic23.h"
#include "bp41.h"
#include "noise_gen.h"
#include "rtdx.h"
#include "target.h"
#include <math.h>
#define BUFSIZE 41
#define MINVOLUME 1
//delay samples
short fb; //feedback variable
shift_reg sreg;
short prn(void) ;
/* Global declarations */
sample inp_buffer[BUFSIZE];
int out_buffer[BUFSIZE];
short buffercount = 0; //init buffer count
const short bufferlength =1024;
Int volume =1;
/* the scaling factor for volume control */
/* RTDX channels */
RTDX_CreateInputChannel(control_channel);
RTDX_CreateInputChannel(A2D_channel);
RTDX_CreateOutputChannel(D2A_channel);
RTDX_CreateOutputChannel(D2A1_channel);
RTDX_CreateOutputChannel(D2A2_channel);
main()
{
int dly[N];
DSK6713_AIC23_CodecHandle hCodec;
while (TRUE) {
/* Read a new volume when the hosts send it */
if (!RTDX_channelBusy(&control_channel)) {
RTDX_readNB(&control_channel, &volume, sizeof(volume));
}
while (!RTDX_isInputEnabled(&A2D_channel)){
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for input*/
#endif
}
RTDX_read(&A2D_channel,input, size*sizeof(sample));
/*
* D2A: produce analog output (send signal to the host through RTDX).
* If D2A_channel is enabled, write data to the host.
*/
RTDX_write(&D2A1_channel,dly, size*sizeof(sample));
while(RTDX_writing){
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
RTDX_write(&D2A2_channel,yn_buffer, size*sizeof(sample));
while(RTDX_writing){
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for output */
#endif
}}}
} //return sequence
Aim:-
To design an IIR filter using DSK-6713 processor.
Coding:-
#include "iirfiltercfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
#include <rtdx.h>
#include "target.h"
#define BUFSIZE 31
#define MINVOLUME 1
typedef Int sample;
Uint32 inp_buffer[BUFSIZE];
Uint32 out_buffer[BUFSIZE];
Int volume = MINVOLUME;
RTDX_CreateInputChannel(control_channel);
RTDX_CreateInputChannel(A2D_channel);
RTDX_CreateOutputChannel(D2A1_channel);
RTDX_CreateOutputChannel(D2A2_channel);
/* Codec configuration settings */
DSK6713_AIC23_Config config = { \
int j,m;
TARGET_INITIALIZE();
RTDX_enableInput(&control_channel);
RTDX_enableInput(&A2D_channel);
RTDX_enableOutput(&D2A1_channel);
RTDX_enableOutput(&D2A2_channel);
/* Start the codec */
hCodec = DSK6713_AIC23_openCodec(0, &config);
DSK6713_AIC23_setFreq(hCodec, 3);
while(1)
{
for(j=0;j<BUFSIZE;j++)
{
l_output=IIR_FILTER(&filter_Coeff ,l_input);
//r_output=l_output;
out_buffer[j]=l_output;
while (!RTDX_isInputEnabled(&A2D_channel)){
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll(); /* poll comm channel for input*/
#endif
}
j=0;
while(size--){
*output++ = out_buffer[j++];
}
size = BUFSIZE;
input = inp_buffer;
output = out_buffer;
/* D2A: produce analog output (send signal to the host through RTDX).
* If D2A_channel is enabled, write data to the host.
*/
/* for(m=0;m<50000;m++)
{
for(m=0;m<50000;m++)
{
}
/* Close the codec */
// DSK6713_AIC23_closeCodec(hCodec);
}}
return (temp<<2);
}
Output :-