clc; clear all; close all; m=3; n=2^m-1; k=n-m; msg=randint(k*200,1,2); code=encode(msg,n,k,'hamming'); codenoisy=rem(code+(rand(n*200,1)>951),2); newmsg=decode(codenoisy,n,k,'hamming'); [codenum,coderate]=symer(code,codenoisy); [msgnum,msgrate]=symer(msg,newmsg); disp(['error rate in the received code'; num2str(coderate)]); disp(['error rate after decoding';num2str(msgrate)]);
RESULT: Error rate in the received code 0.0525855 Error rate after decoding 0.0175
%% Verification of minimum distance in hamming code clc; clear all; close all; echo on; k=4; for i=1;2^k; for j=k;-1:1 if rem (i-1,2^(-j+k+1)>=2^(-j+k)); u(i,j)=1; else u(i,j)=0; end end end g=[1 0 0 0 0 1 1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 0 1] e=rem(u*g,2); wmin=min(sum((e(2:2^k))));
%% Point detection for given image clc; clear all; f=imread('cameraman.tif'); figure,imshow(f); w=[-1 -3 -1; -1 4 -1; -1 -3 -1]; g=abs(imfilter (double(f),w)); t=max(g(:)); g=g>=t; figure,imshow(g);
Connect the cro to the socket provided for lineout. Connect a signal generator to the line socket. Switch on the function generator with a sine wave of frequency 500 MHz. Now on the DSK and bring up code composer studio on the dc. From file menu->new->DSP IBIOS configuration .Selectdisk6713.cdb and save it as yyy.cbb and add it to the current project. Add the generated yyyy.cfg.cmd file to the current project Add the given codec.c file to the current project which has the main function and causes and the other necessary routines. View the contents of generated file yyy.cfg and copy the include header fileyyyfg. to the codec.c file. Add the library file dsk6713bs.lib form the location in e drive to the current project. Add the given above c source file to the current project (remove codec.c source file from the project if you have already added). Build the program. Load the generated object file on the target board. Run the program using F5. Observe the waveform that appears on the cro screen.
PROGRAM:
#include filter fg.h #include dsk 6713.h #includedsk6713.alc23.h Constant signal int filter-coeff[]={1.455,1.455,1.455,32769,-23140,- 21735} Dsk6713-alc23-config={0x0017/40 dsk6713-alc23-leftin-vol left line input volume*/ 0x0013,1*1 dsk6713-alc23- right in vol right line input volume*/ 0x0018,/*2 dsk6713 left hp vol left channel head phone volume*/ 0x00d8,/*3 dsk6713-alc23-right hp vol right channel head phone volume*/ 0x0011,/*4 dsk6713-alc23 path analog audio path control*/ 0x008,/*5 dsk6713-alc23-digif digital audio interface channel*/ 0x000,/*7 dsk6713-alc23-diapath digital audio path channel*/ 0x0081,/48 dsk6713-alc23-sample rate sample rate channel control*/ 0x0001,/4d dsk6713-alc23-digact digital interface activation*/ };
Main() { Dsk6713-alc23 codec #handle h code; Int 1-input,r-input,1-output,r-output; Dsk6713-alc23-set frequency chcode(,3);
While(1) { While(!dsk 6713-alc23-read(hcodec,sinput,1-output) 1ouput= iir filter(filter coeff.1-input); R output=1-output; While(!dsk6713-alc23-write(hcodec,1-output); While(!dsk6713-alc23-write(hcodec,routput); } } Signed int iir-filter(const signed int n,signed int x1); { Static signed int x[6]={0,0,0,0,0,0} Static signed int y[6]={0,0,0,0,0,0} Int temp=0; Temp=(short int)x1; X[0]=(signed int) temp; Temp=((int)h[0]*x[0]); Temp+=((int)h[1]*x[0]); Temp+=((int)h[1]*x[1]); Temp+=((int)h[2]*x[2]); Temp+=((int)h[3]*x[3]); Temp+=((int)h[4]*y[0]); Temp+=((int)h[5]*y[1]); Temp+=((int)h[6]*y[2]); Temp>>=15; If(temp>32727) { Temp=32727; } Elseif(temp<-32727) { Temp=-32727; } Y[0]=temp; Y[2]=y[1]; Y[1]=y[0]; X[2]=x[1]; X[1]=x[0]; Return(temp<<2) }
Dsk6713-alc23-codec handle h codec: Int 32i-input,r-input,1-output,r-output; Dsk6713-init(); Hcodec-dsk6713-alc21-opencodec[0,s config]; Dsk6713-alc23-set frequency (hcode(,1));
While[1] { While (!dsk6713-alc23-read(h codec ,$ 1-input)) While (!dsk6713-alc23-read(h codec ,$ r-input)) 1-output=(int16)f/r-filter($filter-coeff-incient,+input); r-output=1-output; while(!dsk6713-alc23-write(hcodec,1-output); while(!dsk6713-alc23-write(hcodec,r-output); } Dsk6713-alc23-close codec(hcodec); } Signal int f/r filter(float*h,signed intx); { Int i=0; Signed long output=0; Inbuffer [0]=x; For(i=30;i>0:i--); In-buffer[i]-in buffer[i-1]; For[i=0;i<32;i++] Output=output+h[i]*in-buffer[i]; Return(Output);