📄 exp5.html
字号:
<p style='margin-right:72.0pt;margin-left:72.0pt'> </p></form><form><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE5-2 The linker command file for Experiment 5A, 5B, and 5C.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp5.cmd">/* Linker command file for Experiment 5 (C55x memory map) */ MEMORY { SPRAM : origin = 00000c0h, length = 0000040 DARAM0 : origin = 0000100h, length = 0003F00h DARAM1 : origin = 0004000h, length = 0004000h DARAM2 : origin = 0008000h, length = 0004000h DARAM3 : origin = 000c000h, length = 0004000h SARAM0 : origin = 0010000h, length = 0004000h SARAM1 : origin = 0014000h, length = 0004000h SARAM2 : origin = 0018000h, length = 0004000h SARAM3 : origin = 001c000h, length = 0004000h SARAM4 : origin = 0020000h, length = 0004000h SARAM5 : origin = 0024000h, length = 0004000h SARAM6 : origin = 0028000h, length = 0004000h SARAM7 : origin = 002c000h, length = 0004000h SARAM8 : origin = 0030000h, length = 0004000h SARAM9 : origin = 0034000h, length = 0004000h SARAM10 : origin = 0038000h, length = 0004000h SARAM11 : origin = 003c000h, length = 0004000h SARAM12 : origin = 0040000h, length = 0004000h SARAM13 : origin = 0044000h, length = 0004000h SARAM14 : origin = 0048000h, length = 0004000h SARAM15 : origin = 004c000h, length = 0004000h VECS : origin = 0ffff00h, length = 00100h /* reset vector */ }	 SECTIONS { vectors : {} > VECS /* interrupt vector table */ .cinit : {} > SARAM0 .text : {} > SARAM1 .stack : {} > DARAM0 .sysstack: {} > DARAM0 .sysmem : {} > DARAM1 .data : {} > DARAM1 .bss : {} > DARAM1 .const : {} > DARAM1 fir_coef : {} > SARAM0 /* user defined sections */ fir_data : {} > DARAM2 input : {} > SARAM0 output : {} > SARAM0 align 0x4 /* word boundary alignment */ fir_code : {} > SARAM1 isrs : {} > SARAM2 }</TEXTAREA></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p></form><form><div class=MsoNormal align=center style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:72.0pt;text-align:center'><hr size=3 width="100%" align=center></div><p style='margin-right:72.0pt;margin-left:72.0pt'><strong><spanstyle='font-size:13.5pt;color:blue'>Experiment 5A - Block FIR FilterImplementation Using the TMS320C55x</span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>The first experiment isdesigned to demonstrate a lowpass FIR filter implementation using TMS320C55x.The main C function <a href="exp5/exp5a.c"><span style='font-family:"Courier New"'>exp5a.c</span></a>in Table E5-3 and software signal generator listed in Table E5-1 are used toaid the experiment. The FIR filter assembly language implementation <ahref="exp5/fir.asm"><span style='font-family:"Courier New"'>fir.asm</span></a>is given by Table E5-4.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE5-3 The list of C function for Experiment 5A.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="Exp5a">/* exp5a.c - Block FIR filter function experiment using input data file */ #define M 128 /* Input sample size */ #define L 48 /* Number of FIR filter coefficients */ #define SN L /* Signal buffer size */ extern unsigned int fir(int *, unsigned int, int *, unsigned int, int *, int *, unsigned int); /* Define DSP system memory map */ #pragma DATA_SECTION(LP_h, "fir_coef"); #pragma DATA_SECTION(x, "fir_data"); #pragma DATA_SECTION(index, "fir_data"); #pragma DATA_SECTION(out, "output"); #pragma DATA_SECTION(in, "input"); #pragma DATA_SECTION(input, "input"); #pragma CODE_SECTION(main, "fir_code"); /* Input data */ #include "input5.dat" /* Low-pass FIR filter coefficients */ int LP_h[L]={ -6,28,46,27,-35,-100,-93,26,191,240,52,-291,-497,-278, 337,888,773,-210,-1486,-1895,-442,2870,6793,9445, 9445,6793,2870,-442,-1895,-1486,-210,773,888,337, -278,-497,-291,52,240,191,26,-93,-100,-35,27,46,28,-6}; int x[SN]; /* Signal buffer */ unsigned int index; /* Signal buffer index */ int out[M]; /* Output buffer */ int in[M]; /* Input buffer */ void main(void) { unsigned int i,j; /* Initialize filter signal buffer */ for (i=0; i<SN;i++) x[i]=0;	 index = 0; /* Processing samples using a block FIR filter */ j=0; for (;;) { for (i=0; i<M; i++) { in[i]=input[j++];	/* Get a buffer of samples */ if (j == 160) j=0; } index=fir(in,M,LP_h,L,out,x,index); /* FIR filter */ } } </TEXTAREA></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE5-4 The generic block FIR filter routine, <em>fir.asm</em>.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="fir.asm">; ; fir.asm - Generic FIR filter ; ; prototype: unsigned int fir(int *, unsigned int, int *, ; unsigned int, int *, int *, unsigned int);	 ; ; Entry: arg0: AR0 - filter input buffer pointer ; arg1: T0 - number of samples in input buffer ; arg2: AR1 - FIR coefficients array pointer ; arg3: T1 - FIR filter order ; arg4: AR2 - output buffer pointer ; arg5: AR3 - signal buffer pointer ; arg6: AR4 - signal buffer index ; ; Return: T0 = signal buffer index ; .def _fir .sect "fir_code" 	 _fir pshm ST1_55 ; Save ST1, ST2, and ST3 pshm ST2_55 pshm ST3_55 		 or #0x340,mmap(ST1_55); Set FRCT,SXMD,SATD bset SMUL ; Set SMUL mov mmap(AR1),BSA01 ; AR1=base address for coeff mov mmap(T1),BK03	 ; Set coefficient array size mov mmap(AR3),BSA23 ; AR3=base address for signal buffer or #0xA,mmap(ST2_55) ; AR1 & AR3 as circular pointers mov #0,AR1 ; Start from zero offset mov AR4,AR3 ; Start with offset=index sub #1,T0 ; T0=M-1 mov T0,BRC0 ; Init outer loop for M times sub #3,T1,T0 ; T0=L-3 mov T0,CSR ; Init inner loop L-2 times || rptblocal sample_loop-1 ; Start the outer loop mov *AR0+,*AR3 ; Put the new sample to signal buffer mpym *AR3+,*AR1+,AC0 ; Do the 1st operation || rpt CSR ; Start the inner loop macm *AR3+,*AR1+,AC0 macmr *AR3,*AR1+,AC0 ; Do the last operation 	 mov hi(AC0),*AR2+ ; Save Q15 filtered value sample_loop popm ST3_55 ; Restore ST1, ST2, and ST3 popm ST2_55 popm ST1_55	 mov AR3,T0 ; Return signal buffer index || ret .end </TEXTAREA></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 5A,following these steps:</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Createthe project, <span style='font-family:"Courier New"'>exp5a</span> and includethe linker command file <span style='font-family:"Courier New"'>exp5.cmd</span>,the function <span style='font-family:"Courier New"'>exp5a()</span>, the FIRfilter routine <span style='font-family:"Courier New"'>fir()</span>, and thedata file <span style='font-family:"Courier New"'>input5.dat</span>.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Use<span style='font-family:"Courier New"'>rts55.lib</span> for <spanstyle='font-family:"Courier New"'>main()</span> function initialization andbuild the project.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Seta break point at the <span style='font-family:"Courier New"'>for(;;) </span>statementof the <span style='font-family:"Courier New"'>main()</span> function and useCCS graphic function to view the 16-bit integer output in the buffer <spanstyle='font-family:"Courier New"'>out[]</span>, set data length to 128 forviewing one block data a time.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Animatethe filtering process and observe the filter out as a clean sine wave of 800Hz.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l2 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Profilethe FIR filter.</p><p style='margin-right:72.0pt;margin-left:72.0pt'>Figure E5-1 and Figure E5-2show the plots of the first block of input and output samples of Experiment 5Ain frequency and time domain.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><imgborder=0 width=399 height=501 id="_x0000_i1027" src="exp5/input.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE5-1 Input of the filter in frequency and time domain.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><imgborder=0 width=400 height=501 id="_x0000_i1028" src="exp5/output.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE5-2 Output of the filter in frequency and time domain.</p></form><p><a href="#top"><span style='font-size:7.5pt'>Back to Top</span></a> <input type=button value="go back" onclick="history.go(-1)"></p><div class=MsoNormal align=center style='text-align:center'><hr size=3 width="100%" align=center></div><form><p align=center style='text-align:center'><strong><span style='font-size:13.5pt;color:blue'>Experiment 5B - Symmetric FIR Filter Implementation </span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>The purpose of Experiment 5Bis to understand the characteristics of symmetric FIR filters and specialassembly instruction <span style='font-family:"Courier New"'>firsadd</span> ofthe TMS320C55x. The C function <a href="exp5/exp5b.c"><span style='font-family:"Courier New"'>exp5b.c</span></a> is listed in Table E5-5 for reference. Thesymmetric FIR filter assembly routine<span style='font-family:"Courier New"'> </span><ahref="exp5/firsymm.asm"><span style='font-family:"Courier New"'>firsymm.asm</span></a>is given in Table E5-6. Since the firsadd instruction performs threememory-read actions in the same cycle, we need to separate the filtercoefficient array from the signal buffer. We place the signal buffer <spanstyle='font-family:"Courier New"'>x[]</span> in DARAM and coefficient array <spanstyle='font-family:"Courier New"'>LP_h[]</span> in SARAM to allow theinstruction to read two samples in the signal buffer and one coefficient fromthe coefficients array at the same time without data bus conflict. Thisarrangement is done by the linker command file.</p><p align=center style='text-align:center'> </p><p align=center style='text-align:center'>Table E5-5 List of C function forExperiment 5B.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp5b.c">/* exp5b.c - Block Symmetric FIR filter function experiment using input data file */ #define M 128 /* Input sample size */ #define L 48 /* Number of FIR filter coefficients */ #define SN L /* Signal buffer size */ extern unsigned int firsymm(int *, unsigned int, int *, unsigned int, int *, int *, unsigned int); /* Define DSP system memory map */ #pragma DATA_SECTION(LP_h, "fir_coef"); #pragma DATA_SECTION(x, "fir_data"); #pragma DATA_SECTION(index, "fir_data"); #pragma DATA_SECTION(out, "output"); #pragma DATA_SECTION(in, "input"); #pragma DATA_SECTION(input, "input"); #pragma CODE_SECTION(main, "fir_code"); /* Input data */ #include "input5.dat" /* Low-pass FIR filter coefficients (1st half) */ int LP_h[L/2]={ -6,28,46,27,-35,-100,-93,26,191,240,52,-291,-497,-278, 337,888,773,-210,-1486,-1895,-442,2870,6793,9445,}; int x[SN]; /* Signal buffer */ unsigned int index; /* Signal buffer index */ int out[M]; /* Output buffer */ int in[M]; /* Input buffer */ void main(void) { unsigned int i,j; /* Initialize filter signal buffer */ for (i=0; i<SN;i++) x[i]=0;	 index = 0; /* Processing samples using a block symmetric FIR filter */ j=0; for (;;) { for (i=0; i<M; i++) { in[i]=input[j++];	/* Get a buffer of samples */ if (j == 160) j=0; } index=firsymm(in,M,LP_h,L,out,x,index); /* FIR filter */ } } </TEXTAREA></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -