You are on page 1of 26

Introduction The TMS320C6000 digital signal processor (DSP) platform is part of the TMS320 DSP family.

The TMS320C62 DSP generation and the TMS320C6! DSP generation comprise fi ed"point de#ices in the C6000 DSP platform$ and the TMS320C6% DSP generation comprises floating point de#ices in the C6000 DSP platform. The C62 and C6! DSPs are code"compati&le. The C62 and C6% DSPs are code"compati&le. 'll three DSPs (se the )elociT* architect(re$ a high"performance$ ad#anced #ery long instr(ction +ord (),*-) architect(re$ ma.ing these DSPs e cellent choices for m(ltichannel and m(ltif(nction applications.

TMS320C62x DSP Architecture


Figure 1--1 is the block diagram for the C62x DSP. The C6000 devices come with program memory, hich, on some devices, can be used as a program cache. The devices also have varying sizes of datamemory. Peripherals such as a direct memory access (DMA) controller, power-down logic, and external memory interface (EMIF) usually come with the CPU, while peripherals such as serial ports and host ports are on only certain devices. Check your data manual for your device to determine the specific peripheral configurations.

Figure 1--1. TMS320C62x DSP Block Diagram

Central Processing Unit (CPU)


The C62x CPU, in Figure 1--1, contains: - Program fetch unit - Instruction dispatch unit - Instruction decode unit - Two data paths, each with four functional units - 32 32-bit registers - Control registers - Control logic - Test, emulation, and interrupt logic The program fetch, instruction dispatch, and instruction decode units can deliver up to eight 32-bit instructions to the functional units every CPU clock cycle. The processing of instructions occurs in each of the two data paths (A and B), each of which contains four functional units (.L, .S, .M, and .D) and 16 32-bit general-purpose registers. The data paths are described in more detail in Chapter 2. A control register file provides the means to configure and control various processor operations. To understand how instructions are fetched, dispatched, decoded, and executed in the data path, see Chapter 4.

Internal Me or!
The C62x DSP has a 32-bit, byte-addressable address space. Internal (on-chip) memory is organized in separate data and program spaces. When off-chip memory is used, these spaces are unified on most devices to a single memory space via the external memory interface (EMIF). The C62x DSP has two 32-bit internal ports to access internal data memory. The C62x DSP has a single internal port to access internal program memory, with an instruction-fetch width of 256 bits.

Me or! and Peri"heral #"tions


A variety of memory and peripheral options are available for the C6000 platform: - Large on-chip RAM, up to 7M bits - Program cache - 2-level caches - 32-bit external memory interface supports SDRAM, SBSRAM, SRAM, and other asynchronous memories for a broad range of external memory requirements and maximum system performance.
TMS320C62x DSP Architecture 1-8 Introduction SPRU731A - The direct memory access (DMA) controller transfers data between

address ranges in the memory map without intervention by the CPU. The DMA controller has four programmable channels and a fifth auxiliary channel. - The enhanced direct memory access (EDMA) controller (C6211 DSP only) performs the same functions as the DMA controller. The EDMA has 16 programmable channels, as well as a RAM space to hold multiple configurations for future transfers. - The host port interface (HPI) is a parallel port through which a host processor can directly access theCPUmemory space. The host device functions as amaster to the interface, which increases ease of access. The host and CPU can exchange information via internal or external memory. The host also has direct access tomemory-mappedperipherals. Connectivity to the CPU memory space is provided through the DMA/EDMA controller. - The expansion bus is a replacement for the HPI, as well as an expansion of the EMIF. The expansion provides two distinct areas of functionality (host port and I/O port) that can co-exist in a system. The host port of the expansion bus can operate in either asynchronous slavemode, similar to the HPI, or in synchronous master/slave mode. This allows the device to

interface to a variety of host bus protocols. Synchronous FIFOs and asynchronous peripheral I/O devices may interface to the expansion bus. - The peripheral component interconnect (PCI) port supports connection of the C62x DSP to a PCI host via the integrated PCI master/slave bus interface. - The multichannel buffered serial port (McBSP) is based on the standard serial port interface found on the TMS320C2000 and TMS320C5000 devices. In addition, the port can buffer serial samples in memory automatically with the aid of theDMA/EDMAcontroller. It also has multichannel capability compatible with the T1, E1, SCSA, and MVIP networking standards.

$a%&a re"ort

Lab 1 TMS320C6713 DSK and Code Composer Studio


1.1. Introduction
The hardware experiments in the DSP lab are carried out on the Texas Instruments TMS320C67 3 DSP Starter !it "DS!#$ based on the TMS320C67 3 %loatin& point DSP runnin& at 22' M()* The basic cloc+ c,cle instruction time is /(22' M())= -.-- nanoseconds* Durin& each cloc+ c,cle$ up to ei&ht instructions can be carried out in parallel$ achie.in& up to / 22' = /00 million instructions per second "MIPS#* The C67 3 processor has 2'6!0 o% internal memor,$ and can potentiall, address -10 o% external memor,* The DS! board includes a 6M0 SD23M memor, and a ' 2!0 4lash 25M* It has an on6board 66bit audio stereo codec "the Texas Instruments 3IC230# that ser.es both as an 37D and a D73 con.erter* There are %our 3*' mm audio 8ac+s %or microphone and stereo line input$ and spea+er and head6phone outputs* The 3IC23 codec can be pro&rammed to sample audio inputs at the %ollowin& samplin& rates9 fs = /, 6, 2-, 32, --. , -/, :6 +() The 3DC part o% the codec is implemented as a multi6bit third6order noise6shapin& delta6si&ma con.erter "see Ch* 2 ; 2 o% < = %or the theor, o% such con.erters# that allows a .ariet, o% o.ersamplin& ratios that can reali)e the abo.e choices o% fs* The correspondin& o.ersamplin& decimation %ilters act as anti6aliasin& pre%ilters that limit the spectrum o% the input analo& si&nals e%%ecti.el, to the >,?uist inter.al [fs/2, fs/2]* The D3C part is similarl, implemented as a multi6bit second6order noise6shapin& delta6si&ma con.erter whose o.ersamplin& interpolation %ilters act as almost ideal reconstruction %ilters with the >,?uist inter.al as their passband* The DS! also has %our user6pro&rammable DIP switches and %our @ADs that can be used to control and monitor pro&rams runnin& on the DSP* 3ll %eatures o% the DS! are mana&ed b, the CCS$ which is a complete inte&rated de.elopment en.ironment "IDA# that includes an optimi)in& C7CBB compiler$ assembler$ lin+er$ debu&&er$ and pro&ram loader* The CCS communicates with the DS! .ia a CS0 connection to a PC* In addition to %acilitatin& all pro&rammin& aspects o% the C67 3 DSP$ the CCS can also read si&nals stored on the DSPDs memor,$ or the SD23M$ and plot them in the time or %re?uenc, domains* The %ollowin& bloc+ dia&ram depicts the o.erall operations in.ol.ed in all o% the hardware experiments in the DSP lab* Processin& is interrupt6dri.en at the samplin& rate fs$ as explained below* The 3IC23 codec is con%i&ured "throu&h CCS# to operate at one o% the abo.e samplin& rates fs* Aach collected sample is con.erted to a 66bit twoDs complement inte&er "a s ort data t,pe in C#* The codec actuall, samples the audio input in stereo$ that is$ it collects two samples %or the le%t and ri&ht channels* 3t each samplin& instant$ the codec combines the two 66bit le%t7ri&ht samples into a sin&le 326bit unsi&ned inte&er word "an unsi!ned int$ or "int32 data t,pe in C#$ and ships it o.er to a 326bit recei.ere&ister o% the multichannel bu%%ered serial port "Mc0SP# o% the C67 3 processor$ and then issues an interrupt to the processor* Cpon recei.in& the interrupt$ the processor executes an interrupt ser.ice routine "IS2# that implements a desired sample processin& al&orithm pro&rammed with the CCS "e*&*$ %ilterin&$ audio e%%ects$ etc*#* Durin& the IS2$ the %ollowin& actions ta+e place9 the 326bit input sample "denoted b, x in the dia&ram# is read %rom the Mc0SP$ and sent into the sample processin& al&orithm that computes the correspondin& TMS320C67 3 DS! 3>D C5DA C5MP5SA2 STCDI5 / 326bit output word "denoted b, y#$ which is then written bac+ into a 326bit transmit6re&ister o% the Mc0SP$ %rom where it is trans%erred to the codec and reconstructed into analo& %ormat$ and %inall, the IS2 returns %rom interrupt$ and the processor be&ins waitin& %or the next interrupt$ which will come at the next samplin& instant*

Clearl,$ all processin& operations durin& the execution o% the IS2 must be completed in the time inter.al between samples$ that is$ T = /fs* 4or example$ i% fs = --. +()$ then$ T = /fs = 22.6/ sec* Eith an instruction c,cle time o% Tc = -.-- nsec$ this allows T/Tc = ' 0/ c,cles to be executed durin& each samplin& instant$ or$ up to /' 0/ = -0/6- instructions$ or hal% o% that per channel*

/0a1 'rite a c "rogra that "ro "ts a user to enter a s all no and then calculate its (actorial) Print the *alue and its (actorial in a nicel! (or atted (ashion) De onstrate ho+ !ou can single ste" through this "rogra +hile +atching the (actorial *alue gro+) Include listing in !our re"ort as listing &)

2incl(de3stdio.h4 2incl(de3math.h4 int fact5 66 initiali7ed #aria&le fact int n$i5 66 initiali7ed #aria&le n and i main() 8 fact905 printf(:enter a1:)5 scanf(:;d:$<n)5 66 ta.e inp(t from (ser for(i905i39n5i==) 66for loop +ith test condition 8 fact9fact>i5 ? printf(:'ns+er of factorial is9 ;d:$fact)5 66print final ans+er of factorial ? Demonstrating single step1 De&(g option can &e (sed for #ario(s p(rposes. To e amine single stepping +e need to (se3 @004 .ey. *t demonstrates the program in single stepping. 3@A4 .ey can &e (sed to step into f(nction.

,a& report part 2a


/2a1 Modify the interr(pt ser#ice ro(tine to play the left channel only. 6> interr(pt dri#en sampling program for B)M6%00>6 2incl(de 3stdio.h4 2incl(de 3stdli&.h4 2incl(de 3string.h4 2incl(de 3Mc&spdr#.h4 6> mc&sp dri#er>6 2incl(de 3Common.h4 2incl(de 3*ntr.h4 2incl(de 3Coard.h4 6> B)M li&rary >6 2incl(de 3Codec.h4 6> codec li&rary >6 2incl(de 3Mc&sp.h4 2incl(de 3mathf.h4 #oid hoo.int(#oid)5 interr(pt #oid McCSPDc#*SD(#oid)5 6>int delayE!000F5 int inde 905 int delayGlineGo(tp(t5 >6 int main() 8 Mc&spGde# de#5 Mc&spGconfig mc&spConfig5 int sampleDate$'ct(alGSamplingGDate5 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> *nitiali7e B)M >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 printf(:*nitiali7ing B)M &oardHn:)5 e#mGinit()5 printf(:Done initiali7ing B)MHn:)5 printf (:Hn;d:$cp(GfreI())5 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> Jpen MCCSP >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 mc&spGdr#Ginit()5 6>initiali7e McCSP dri#er$ allocates memory for the de#ice handles >6 de#9 mc&spGopen(0)5 if (de# 99 KL,,) 8 printf(:Brror opening MCCSP 0 Hn :)5 ret(rn(BDDJD)5

? 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> config(re McCSP >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 memset(<mc&spConfig$0$si7eof(mc&spConfig))5 mc&spConfig.loop&ac. 9 @',SB5 mc&spConfig.t .(pdate 9 TDLB5 mc&spConfig.t .cloc.Gpolarity 9 C,MNGPJ,GD*S*KO5 mc&spConfig.t .cloc.Gmode 9 C,MGMJDBGBNT5 mc&spConfig.t .frameGlength0 9 05 mc&spConfig.t .+ordGlength0 9 -JDDG,BKOTPG325 mc&spConfig.r .(pdate 9 TDLB5 mc&spConfig.r .cloc.Gmode 9 C,MGMJDBGBNT5 mc&spConfig.r .frameGlength0 9 05 mc&spConfig.r .+ordGlength0 9 -JDDG,BKOTPG325 mc&spGconfig(de#$<mc&spConfig)5 6>config(re>6 MCCSPGBK'C,B(0$MCCSPGCJTP)5 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> config(re CJDBC >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 codecGinit()5 6> '6D 0.0 dC gain$ t(rn on 20dC mic gain$ sel (,6D)M*C as inp(ts >6 codecGadcGcontrol(,B@T$0.0$TDLB$M*CGSB,)5 codecGadcGcontrol(D*OPT$0.0$TDLB$M*CGSB,)5 66codecGlineGinGcontrol(,B@T$M*KG'LNG,*KBGO'*K$@',SB)5 66codecGlineGinGcontrol(D*OPT$M*KG'LNG,*KBGO'*K$@',SB)5 codecGdacGcontrol(,B@T$0.0$@',SB)5 codecGdacGcontrol(D*OPT$0.0$@',SB)5 sampleDate9!!0005 'ct(alGSamplingGDate9 codecGchangeGsampleGrate(sampleDate$ TDLB)5 printf(:The act(al sampling rate is 9 ;dHn:$ 'ct(alGSamplingGDate)5 6>for (inde 905inde 3!0005inde ==) 66clears delay &(ffer delayEinde F905 >6 codecGinterr(ptGena&le()5 hoo.int()5 6>Main loop>6 +hile (0) 8 ? ? #oid hoo.int() 8 intrGinit()5 intrGmap(CPLG*KT0Q$*SKGD*KT0)5

intrGhoo.(McCSPDc#*SD$CPLG*KT0Q)5 *KTDGBK'C,B(0Q)5 *KTDGO,JC',GBK'C,B()5 ret(rn5 ? interr(pt #oid McCSPDc#*SD(#oid) 8 int temp5 temp9MCCSPGDB'D(0)5 temp9temp44065 if (temp < 0 A000) temp 9 temp R0 ffff00005 66temp9(temp < 0 ffff0000)5 66 delayGlineGo(tp(t 9 temp = delayEinde F>0.%Q5 66 delayGlineGo(tp(t 9 delayGlineGo(tp(t33065 MCCSPG-D*TB(0$temp)5 6>delayEinde F 9 temp5 inde ==5 if (inde 49!000) inde 9 05 >6 ?

,o+

odi(! the interru"t ser*ice routine to "la! the right channel onl!)

interr(pt #oid McCSPDc#*SD(#oid) 8 int temp5 temp9MCCSPGDB'D(0)5 temp9temp44065 if (temp < 0 A000) temp 9 temp R0 0000ffff5 66temp9(temp < 0 0000ffff)5 66 delayGlineGo(tp(t 9 temp = delayEinde F>0.%Q5 66 delayGlineGo(tp(t 9 delayGlineGo(tp(t33065

MCCSPG-D*TB(0$temp)5 6>delayEinde F 9 temp5 inde ==5 if (inde 49!000) inde 9 05 >6 ?

,o+ odi(! the interru"t ser*ice routine to "la! %oth channels) *nt C5 interr(pt #oid McCSPDc#*SD(#oid) 8 int temp5 temp9MCCSPGDB'D(0)5 temp9temp44065 if (C990) 8 else if (temp < 0 A000) temp 9 temp R0 ffff00005 66temp9(temp < 0 ffffffff)5 C905 ? else if 8

if (temp < 0 A000) temp 9 temp R0 0000ffff5 66temp9(temp < 0 ffffffff)5 C905 ?

66 66

delayGlineGo(tp(t 9 temp = delayEinde F>0.%Q5 delayGlineGo(tp(t 9 delayGlineGo(tp(t33065 MCCSPG-D*TB(0$temp)5 6>delayEinde F 9 temp5 inde == if (inde 49!000) inde 9 05 >6

? B plaination1 @or left channel in the interr(pt ser#ice ro(tine $ +e made the lo+er !"&its as high5 and for the right channel +e made the higher !"&its high.

/2&1 Ta&le ,0.2& -uant) .it 06 A 6 ! 2 0

'ord & Pello Pello Pello Pello Pello Pello

'ord 2 Dight Dight Dight Dight Dight Dight

'ord 3 Center Center Center Center Center Center

'ord / @or+ard @or+ard @or+ard @or+ard @or+ard @or+ard

'ord 0 Cac.+ard Cac.+ard Cac.+ard Cac.+ard Cac.+ard Cac.+ard

1 S0 A0 60 !Q 30 20

Include the odi(ied IS2 listing that "ro*ides /3%it 4uanti5ation as listing $&)2%) interru"t *oid Mc.SP2c*IS2(*oid)6 8 int temp5 temp9MCCSPGDB'D(0)5 temp9temp44065 if (temp < 0 A000) temp 9 temp R0 000000005

66 66

66temp9(temp < 0 ffff0000)5 delayGlineGo(tp(t 9 temp = delayEinde F>0.%Q5 delayGlineGo(tp(t 9 delayGlineGo(tp(t33065 MCCSPG-D*TB(0$temp)5 6>delayEinde F 9 temp5 inde ==5 if (inde 49!000) inde 9 05 >6

,a& report 3a /01 generate sine +a#e (sing DSP chip 66template.c " to &e (sed as starting point for interr(pt"&ased programs 66 DSP la& 602$ Department of 'pplied Physics$ Lni#ersity of Marachi. 66"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2incl(de 3stdio.h4 2incl(de 3stdli&.h4 2incl(de 3string.h4

2incl(de 3Mc&spdr#.h4 6> mc&sp dri#er>6 2incl(de 3Common.h4 2incl(de 3*ntr.h4 2incl(de 3Coard.h4 6> B)M li&rary 2incl(de 3Codec.h4 6> codec li&rary 2incl(de 3Mc&sp.h4 2incl(de 3mathf.h4 2incl(de 3math.h4 662define P*93.0!0QS26Q3QAS%S3 interr(pt #oid McCSPDc#*SD(#oid)5 #oid hoo.int(#oid)5 #oid initiali7e(#oid)5 #oid readGinp(ts(short >$ short >)5 #oid +riteGo(tp(ts(short$short)5 #oid a(dioGso(rce(int)5 #oid samplingGrate(short)5 int I+rap(int$ int)5 float +a#gen(int$float >$ float$ float$ int >)5 (nion 8 (nsigned int (5 short cE2F5 ? codec5

>6 >6

short ,$ D$y,$yD5 66left and right inp(t and o(tp(t samples from6to codec float g905 2define D !000 2define K 02A short fs9A5 float c$'9Q000$f90.25 float +EDF5 float &(fferEKF5 int I90$.905 66here$ add more glo&al #aria&le declarations$ 2defineTs$ 2incl(deTs$ etc 66""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

#oid main() 8 int n5

float pi 9 !>atanf(0)5 for (n905 n3D5 n==) +EnF9sinf(2>pi>n6D)5 66c9D>f6fs5 initiali7e()5 66initiali7e the B)M &oard and codec$ define interr(pts samplingGrate(fs)5 66A$26$2!$..!A.h7 a(dioGso(rce(,*KBGSB,)5 66,*KB or M*C for line or microphone inp(t +hile(0)5 66.eep +aiting for interr(pt$ then U(mp to isr()

? #oid initiali7e() 8 Mc&spGde# de#5 Mc&spGconfig mc&spConfig5 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> *nitiali7e B)M >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 printf(:*nitiali7ing B)M &oardHn:)5 e#mGinit()5 printf(:Done initiali7ing B)MHn:)5 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> Jpen MCCSP >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 mc&spGdr#Ginit()5 6>initiali7e McCSP dri#er$ allocates memory for the de#ice handles >6 de#9 mc&spGopen(0)5 if (de# 99 KL,,) 8 printf(:Brror opening MCCSP 0 Hn :)5 66ret(rn(BDDJD)5 ? 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> config(re McCSP >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 memset(<mc&spConfig$0$si7eof(mc&spConfig))5 mc&spConfig.loop&ac. 9 @',SB5 mc&spConfig.t .(pdate 9 TDLB5 mc&spConfig.t .cloc.Gpolarity 9 C,MNGPJ,GD*S*KO5 mc&spConfig.t .cloc.Gmode 9 C,MGMJDBGBNT5

mc&spConfig.t .frameGlength0 9 05 mc&spConfig.t .+ordGlength0 9 -JDDG,BKOTPG325 mc&spConfig.r .(pdate 9 TDLB5 mc&spConfig.r .cloc.Gmode 9 C,MGMJDBGBNT5 mc&spConfig.r .frameGlength0 9 05 mc&spConfig.r .+ordGlength0 9 -JDDG,BKOTPG325 mc&spGconfig(de#$<mc&spConfig)5 6>config(re>6 MCCSPGBK'C,B(0$MCCSPGCJTP)5 ? #oid samplingGrate(short sampleDate) 8 int 'ct(alGSamplingGDate5 sampleDate9 sampleDate>00005 'ct(alGSamplingGDate9 codecGchangeGsampleGrate(sampleDate$ TDLB)5 printf(:The act(al sampling rate is 9 ;dHn:$ 'ct(alGSamplingGDate)5 ? #oid a(dioGso(rce(int SJLDCB) 8 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 6> config(re CJDBC >6 6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>6 codecGinit()5 if (SJLDCB 99 0) 6> '6D 0.0 dC gain$ t(rn on 20dC mic gain$ sel (,6D)M*C as inp(ts >6 8 codecGadcGcontrol(,B@T$M*KG'DCG*KPLTGO'*K$@',SB$,*KBGSB,)5 66select line"in codecGadcGcontrol(D*OPT$M*KG'DCG*KPLTGO'*K$@',SB$,*KBGSB,)5 ? else if (SJLDCB 99 2) 66selects Mic as inp(t 8 codecGadcGcontrol(,B@T$0.0$TDLB$M*CGSB,)5 codecGadcGcontrol(D*OPT$0.0$TDLB$M*CGSB,)5 ? codecGlineGinGcontrol(,B@T$M*KG'LNG,*KBGO'*K$@',SB)5 codecGlineGinGcontrol(D*OPT$M*KG'LNG,*KBGO'*K$@',SB)5 codecGdacGcontrol(,B@T$0.0$@',SB)5 codecGdacGcontrol(D*OPT$0.0$@',SB)5 codecGinterr(ptGena&le()5 hoo.int()5 #oid hoo.int()

8 intrGinit()5 intrGmap(CPLG*KT0Q$*SKGD*KT0)5 intrGhoo.(McCSPDc#*SD$CPLG*KT0Q)5 *KTDGBK'C,B(0Q)5 *KTDGO,JC',GBK'C,B()5 ret(rn5 ? interr(pt #oid McCSPDc#*SD(#oid) 8 readGinp(ts(< D$< ,)5 y,9 +a#gen(D$+$'$f6fs$<I)5 &(fferE.F9(float) y,5 if (==. 49K) .905 +riteGo(tp(ts(y,$y,)5 ?

#oid readGinp(ts(short > D$ short > ,) 8 codec.( 9 MCCSPGDB'D(0)5 66read 32"&it n(m&er > D9 codec.cE0F5 > ,9 codec.cE0F5 ? #oid +riteGo(tp(ts (short yD$ short y,) 8 codec.cE0F9 yD5 codec.cE0F9 y,5 MCCSPG-D*TB(0$codec.()5

float +a#gen(int D $ float >+$ float '$ float @$ int >I) 8 float y$ c9D >@5 y9'>+E>IF5 >I 9 I+rap(D "0$ (int) (>I=c))5 ret(rn y5 ?

int I+rap(int D $ int I) 8 if (I 4 D ) I "9 D=05 if (I 3 0) I =9 D =05 ret(rn I5 ?

,a& report ! Cand stop filter Matla& so(rce code


clc close all clear all Fs=8e3; Ts=1/Fs; Ns=512; t=[0:Ts:Ts*(Ns-1)]; f1=500; f2=1800; f3=2000; f4=3200; x1=s x2=s x3=s x4=s !(2*" !(2*" !(2*" !(2*" *f1*t); *f2*t); *f3*t); *f4*t);

x=x1#x2#x3#x4; $r % o!;

N=1&; '=[0(4 0(&]; )=F*+1(N,',-./-1-); 0)=321&1(*/ ) 2=1; fre34(),2); 0"a5se; f $5re; s56"lot(2,1,1); N"ts=200; "lot(t(1:N"ts),x(1:N"ts)); xla6el(-t 7e (s)-); 8la6el(-F ltere% 9 $-); 0"a5se; 8=f lter(),2,x); "lot(t(1:N"ts),8(1:N"ts)); 0f $5re; s56"lot(2,1,2); xfft7a$=(a6s(fft(x,Ns))); xfft7a$:=xfft7a$(1:le!$t:(xfft7a$)/2); f=[1:1:le!$t:(xfft7a$:)]*Fs/Ns; "lot(f,xfft7a$:); t tle(-*!"5t a!% ;5t"5t 9"ectra-); xla6el(-fre3 (<4)-); 8la6el(-*!"5t s"ectr57-); s56"lot(2,1,2); 8fft7a$=(a6s(fft(8,Ns))); 8fft7a$:=8fft7a$(1:le!$t:(8fft7a$)/2); "lot(f,8fft7a$:); xla6el(-fre3(<4)-); 8la6el(-F lt 9 $ 9"ectr57-);

Coefficients C9 Col(mns 0 thro(gh % "0.003A 0.0000 0.020A 0.0000 "0.0A20 0.0000 0.062Q

Col(mns A thro(gh 0! 0.0000 0.A030 0.0000 0.062Q 0.0000 "0.0A20 0.0000

Col(mns 0Q thro(gh 0%

0.020A fig(re

0.0000 "0.003A

C so(rce code Ta&le ,!.0 B planation Cand pass filter Matla& so(rce code
clc close all clear all Fs=8e3; Ts=1/Fs; Ns=512; t=[0:Ts:Ts*(Ns-1)];

f1=500; f2=1800; f3=2000; f4=3200; x1=s x2=s x3=s x4=s !(2*" !(2*" !(2*" !(2*" *f1*t); *f2*t); *f3*t); *f4*t);

x=x1#x2#x3#x4; $r % o!; N=1&; '=[0(4 0(&]; )=F*+1(N,',-./-0-); 0)=321&1(*/ ) 2=1; fre34(),2); 0"a5se; f $5re; s56"lot(2,1,1); N"ts=200; "lot(t(1:N"ts),x(1:N"ts)); xla6el(-t 7e (s)-); 8la6el(-F ltere% 9 $-); 0"a5se; 8=f lter(),2,x); "lot(t(1:N"ts),8(1:N"ts)); 0f $5re; s56"lot(2,1,2); xfft7a$=(a6s(fft(x,Ns))); xfft7a$:=xfft7a$(1:le!$t:(xfft7a$)/2); f=[1:1:le!$t:(xfft7a$:)]*Fs/Ns; "lot(f,xfft7a$:); t tle(-*!"5t a!% ;5t"5t 9"ectra-); xla6el(-fre3 (<4)-); 8la6el(-*!"5t s"ectr57-); s56"lot(2,1,2); 8fft7a$=(a6s(fft(8,Ns))); 8fft7a$:=8fft7a$(1:le!$t:(8fft7a$)/2); "lot(f,8fft7a$:); xla6el(-fre3(<4)-); 8la6el(-F lt 9 $ 9"ectr57-);

Coefficient C9

Col(mns 0 thro(gh % 0.00Q0 "0.0000 "0.02S! Col(mns A thro(gh 0! "0.0000 0.2%00 "0.0000 "0.20S3 "0.0000 0.000% 0.0000 0.0000 0.000% "0.0000 "0.20S3

Col(mns 0Q thro(gh 0% "0.02S! "0.0000 @ig(re 0.00Q0

C so(rce code Ta&le ,!.2 B planation Pigh pass filter Matla& so(rce code
clc

close all clear all Fs=8e3; Ts=1/Fs; Ns=512; t=[0:Ts:Ts*(Ns-1)]; f1=500; f2=1800; f3=2000; f4=3200; x1=s x2=s x3=s x4=s !(2*" !(2*" !(2*" !(2*" *f1*t); *f2*t); *f3*t); *f4*t);

x=x1#x2#x3#x4; $r % o!; N=1&; '=[0(=25]; )=F*+1(N,',-: $:-); 0)=321&1(*/ ) 2=1; fre34(),2); 0"a5se; f $5re; s56"lot(2,1,1); N"ts=200; "lot(t(1:N"ts),x(1:N"ts)); xla6el(-t 7e (s)-); 8la6el(-F ltere% 9 $-); 0"a5se; 8=f lter(),2,x); "lot(t(1:N"ts),8(1:N"ts)); 0f $5re; s56"lot(2,1,2); xfft7a$=(a6s(fft(x,Ns))); xfft7a$:=xfft7a$(1:le!$t:(xfft7a$)/2); f=[1:1:le!$t:(xfft7a$:)]*Fs/Ns; "lot(f,xfft7a$:); t tle(-*!"5t a!% ;5t"5t 9"ectra-); xla6el(-fre3 (<4)-); 8la6el(-*!"5t s"ectr57-); s56"lot(2,1,2); 8fft7a$=(a6s(fft(8,Ns))); 8fft7a$:=8fft7a$(1:le!$t:(8fft7a$)/2); "lot(f,8fft7a$:);

xla6el(-fre3(<4)-); 8la6el(-F lt 9 $ 9"ectr57-);

coefficients C9 Col(mns 0 thro(gh % 0.00Q0 "0.00AA 0.00S0 "0.0360 0.0QA6 "0.0A30 0.00Q3

Col(mns A thro(gh 0! "0.020A 0.026! "0.020A 0.00Q3 "0.0A30 0.0QA6 "0.0360

Col(mns 0Q thro(gh 0% 0.00S0 "0.00AA @ig(re 0.00Q0

C so(rce code

Ta&le ,!.3 B planation ,o+ pass filter Matla& so(rce code


clc close all clear all Fs=8e3; Ts=1/Fs; Ns=512; t=[0:Ts:Ts*(Ns-1)]; f1=500; f2=1800; f3=2000; f4=3200; x1=s x2=s x3=s x4=s !(2*" !(2*" !(2*" !(2*" *f1*t); *f2*t); *f3*t); *f4*t);

x=x1#x2#x3#x4; $r % o!; N=1&; '=[0(=25]; )=F*+1(N,',-lo>-); 0)=321&1(*/ ) 2=1; fre34(),2); 0"a5se; f $5re; s56"lot(2,1,1); N"ts=200; "lot(t(1:N"ts),x(1:N"ts)); xla6el(-t 7e (s)-); 8la6el(-F ltere% 9 $-); 0"a5se; 8=f lter(),2,x); "lot(t(1:N"ts),8(1:N"ts)); 0f $5re; s56"lot(2,1,2); xfft7a$=(a6s(fft(x,Ns))); xfft7a$:=xfft7a$(1:le!$t:(xfft7a$)/2); f=[1:1:le!$t:(xfft7a$:)]*Fs/Ns; "lot(f,xfft7a$:);

t tle(-*!"5t a!% ;5t"5t 9"ectra-); xla6el(-fre3 (<4)-); 8la6el(-*!"5t s"ectr57-); s56"lot(2,1,2); 8fft7a$=(a6s(fft(8,Ns))); 8fft7a$:=8fft7a$(1:le!$t:(8fft7a$)/2); "lot(f,8fft7a$:); xla6el(-fre3(<4)-); 8la6el(-F lt 9 $ 9"ectr57-);

Coefficients C9 Col(mns 0 thro(gh % "0.0030 0.00Q2 "0.0003 0.020Q "0.03!S 0.0!SQ "0.062%

Col(mns A thro(gh 0! 0.0%0S 0.S2%6 0.0%0S "0.062% 0.0!SQ "0.03!S 0.020Q

Col(mns 0Q thro(gh 0% "0.0003 @ig(re 0.00Q2 "0.0030

C so(rce code Ta&le ,!.! B planation @i ed point @*D filter


clc close all clear all Fs=8e3; Ts=1/Fs; Ns=512; t=[0:Ts:Ts*(Ns-1)]; f1=500; f2=1800; f3=2000; f4=3200; x1=s x2=s x3=s x4=s !(2*" !(2*" !(2*" !(2*" *f1*t); *f2*t); *f3*t); *f4*t);

x=x1#x2#x3#x4;

$r % o!; N=1&; '=[0(=25]; /=F*+1(N,',-: $:-); )=321&1(*/; 0for F xe% "o !t F*+ f lter 75lt "l8 eac: coeff c e!t 68 ) 0 0x1fff t: s > ll co!?ert t:ese or $!al float !$ "o !t coeff c !t 2=1; 0 !to s $! 1&-6 t !te$er fre34(),2); 0"a5se; f $5re; s56"lot(2,1,1); N"ts=200; "lot(t(1:N"ts),x(1:N"ts)); xla6el(-t 7e (s)-); 8la6el(-F ltere% 9 $-); 0"a5se; 8=f lter(),2,x); "lot(t(1:N"ts),8(1:N"ts)); 0f $5re; s56"lot(2,1,2); xfft7a$=(a6s(fft(x,Ns))); xfft7a$:=xfft7a$(1:le!$t:(xfft7a$)/2); f=[1:1:le!$t:(xfft7a$:)]*Fs/Ns; "lot(f,xfft7a$:); t tle(-*!"5t a!% ;5t"5t 9"ectra-); xla6el(-fre3 (<4)-); 8la6el(-*!"5t s"ectr57-); s56"lot(2,1,2); 8fft7a$=(a6s(fft(8,Ns))); 8fft7a$:=8fft7a$(1:le!$t:(8fft7a$)/2); "lot(f,8fft7a$:); xla6el(-fre3(<4)-); 8la6el(-F lt 9 $ 9"ectr57-);

Coefficients C9 0.0e=003 > Col(mns 0 thro(gh % 0.06%0 "0.2A%S 0.6202 "0.0A0S 0.S0SQ "2.%2!3 3.!Q0S

Col(mns A thro(gh 0! "3.SQS0 !.0!00 "3.SQS0 3.!Q0S "2.%2!3 0.S0SQ "0.0A0S

Col(mns 0Q thro(gh 0% 0.6202 "0.2A%S fig(re 0.06%0

C so(rce code Ta&le ,!.Q B planation