⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exp5.html

📁 (Ebook-Pdf) Dsp - Real Time Digital Signal Processing (Usando Tms320-55Xx). 有书
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<p align=center style='text-align:center'>&nbsp;</p><p align=center style='text-align:center'>Table E5-6 Symmetric FIR filterassembly routine.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="firsymm.asm">;&#13;&#10;;   firsymm.asm - Symmetric FIR filter &#13;&#10;;                 (for even # of coefficients)&#13;&#10;;&#13;&#10;;   prototype: unsigned int firsymm(int *, unsigned int, int *, &#13;&#10;;                    unsigned int, int *, int *, unsigned int);&#9;                           &#13;&#10;;&#13;&#10;;    Entry: arg0: AR0 - filter input buffer pointer   &#13;&#10;;           arg1: T0  - number of samples in the input buffer&#13;&#10;;           arg2: AR1 - FIR coefficients array pointer     &#13;&#10;;           arg3: T1  - FIR filter order&#13;&#10;;           arg4: AR2 - filter output buffer pointer&#13;&#10;;           arg5: AR3 - signal buffer pointer  &#13;&#10;;           arg6: AR4 - signal buffer index    &#13;&#10;;&#13;&#10;;    Return: T0 = signal buffer index&#13;&#10;;&#13;&#10;&#13;&#10;    .def  _firsymm&#13;&#10;    .sect &quot;fir_code&quot;&#13;&#10;&#9;&#13;&#10;_firsymm&#13;&#10;    pshm  ST1_55                ; Save ST1, ST2, and ST3&#13;&#10;    pshm  ST2_55&#13;&#10;    pshm  ST3_55&#13;&#10;    &#13;&#10;    mov&#9;  mmap(T1),BK03         ; Set signal buffer size = L&#9;&#13;&#10;    or    #0x340,mmap(ST1_55)   ; Set FRCT,SXMD,SATD   &#13;&#10;    bset  SMUL                  ; Set SMUL&#13;&#10;    mov   XAR1,XCDP             ; CDP as coefficient pointer&#13;&#10;    mov   mmap(AR1),BSAC        ; Set up base address for CDP&#13;&#10;    sfts  T1,#-1                ; T1 = L/2&#13;&#10;||  mov   #0,CDP                ; Start from the 1st coefficient &#13;&#10;    mov   mmap(T1),BKC          ; Set the coefficient array size&#13;&#10;    mov   XAR3,XAR1             ; AR1 &amp; AR3 are signal buffer pointers&#13;&#10;    mov   mmap(AR3),BSA01       ; Set base address of AR1&#13;&#10;    mov   mmap(AR3),BSA23       ; Set base address of AR3     &#13;&#10;    or    #0x10A,mmap(ST2_55)   ; CDP, AR1, AR3 are circular pointers&#13;&#10;    mov   AR4,AR3               ; AR3 is the Head of signal buffer &#13;&#10;    mov   AR4,AR1               ; AR1 is the Tail of signal buffer  &#13;&#10;    sub   #1,T0&#13;&#10;    amar  *AR1-                 ; Adjust tail starting point&#13;&#10;||  mov   T0,BRC0               ; Outer loop counter M blocks &#13;&#10;    sub   #3,T1,T0              ; Inner loop for (L/2-2) iteration&#13;&#10;    mov   T0,CSR&#13;&#10;    mov   T1,T0                 ; Set up update offset for AR1&#13;&#10;    sub   #2,T1                 ; Set up update offset for AR3&#13;&#10;    mov   *AR0+,AC1             ; Get the first sample&#13;&#10;||  rptblocal sample_loop-1     ; To prevent overflow in addition&#13;&#10;    mov   #0,AC0                ;   the input is scaled to Q14 format&#13;&#10;||  mov   AC1&lt;&lt;#-1,*AR3         ; Put input to signal buffer in Q14&#13;&#10;    add   *AR3+,*AR1-,AC1       ; AC1=[x(n)+x(n-L+1)]&lt;&lt;16&#13;&#10;||  rpt   CSR                   ; Do L/2-2 iterations&#13;&#10;    firsadd *AR3+,*AR1-,*CDP+,AC1,AC0    &#13;&#10;    firsadd *(AR3-T0),*(AR1+T1),*CDP+,AC1,AC0 &#13;&#10;    macm  *CDP+,AC1,AC0         ; Finish the last macm instruction&#13;&#10;    mov&#9;  rnd(hi(AC0&lt;&lt;1)),*AR2+ ; Store the rounded &amp; scaled result&#13;&#10;||  mov   *AR0+,AC1             ; Get next sample&#13;&#10;sample_loop&#13;&#10;&#13;&#10;    popm  ST3_55                ; Restore ST1, ST2, and ST3   &#13;&#10;    popm  ST2_55&#13;&#10;    popm  ST1_55&#13;&#10;    mov   AR3,T0                ; Return signal buffer index&#13;&#10;||  ret&#13;&#10;    .end             &#13;&#10;</TEXTAREA></p><p align=center style='text-align:center'>&nbsp;</p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 5B,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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Createthe project, <span style='font-family:"Courier New"'>exp5b</span> and includethe linker command file <span style='font-family:"Courier New"'>exp5.cmd</span>,the function <span style='font-family:"Courier New"'>exp5b()</span>, and theFIR filter routine <span style='font-family:"Courier New"'>firsymm()</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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </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 for viewingone 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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Profilethe symmetric FIR filter and compare the result with Experiment 5A.</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 5C - FIR Filter Implementation Using Dual_MAC</span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>Since the TMS320C55x hasdual_MAC units. It is possible to compute two FIR filter output samples inparallel. Experiment 5C demonstrates how an FIR filter can be implemented inparallel using the dual-MAC characteristics of the DSP. Table E5-7 and TableE5-8 give the function <a href="exp5/exp5c.c"><span style='font-family:"Courier New"'>exp5c.c</span></a>and assembly fir routine<span style='font-family:"Courier New"'> </span><ahref="exp5/fir2macs.asm"><span style='font-family:"Courier New"'>fir2mac.asm</span></a>,respectively.</p><p style='margin-right:72.0pt;margin-left:72.0pt'>&nbsp;</p><p align=center style='text-align:center'>Table E5-7 List of C function forExperiment 5C.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp5c.c">/* &#13;&#10;   exp5c.c - Dual-MAC block FIR filter function experiment&#13;&#10;             using input data file&#13;&#10;*/&#13;&#10;#define M    128       /* Input sample size */&#13;&#10;#define L     48       /* Number of FIR filter coefficients */&#13;&#10;#define SN   L+1       /* Signal buffer size */&#13;&#10;extern unsigned int fir2macs(int *, unsigned int, int *, unsigned int, int *, int *, unsigned int);&#13;&#10;&#13;&#10;/* Define DSP system memory map */&#13;&#10;#pragma DATA_SECTION(LP_h, &quot;fir_coef&quot;);&#13;&#10;#pragma DATA_SECTION(x, &quot;fir_data&quot;);&#13;&#10;#pragma DATA_SECTION(index, &quot;fir_data&quot;);&#13;&#10;#pragma DATA_SECTION(out, &quot;output&quot;);&#13;&#10;#pragma DATA_SECTION(in, &quot;input&quot;);&#13;&#10;#pragma DATA_SECTION(input, &quot;input&quot;);    &#13;&#10;#pragma CODE_SECTION(main, &quot;fir_code&quot;);    &#13;&#10;&#13;&#10;/* Input data */&#13;&#10;#include &quot;input5.dat&quot;&#13;&#10;                                        &#13;&#10;/* Low-pass FIR filter coefficients */  &#13;&#10;static int LP_h[L]={  &#13;&#10;-6,28,46,27,-35,-100,-93,26,191,240,52,-291,-497,-278,&#13;&#10;337,888,773,-210,-1486,-1895,-442,2870,6793,9445,&#13;&#10;9445,6793,2870,-442,-1895,-1486,-210,773,888,337,&#13;&#10;-278,-497,-291,52,240,191,26,-93,-100,-35,27,46,28,-6};&#13;&#10;&#13;&#10;int x[SN];             /* Signal buffer */&#13;&#10;unsigned int index;    /* Signal buffer index */&#13;&#10;int out[M];            /* Output buffer */&#13;&#10;int in[M];             /* Input buffer */&#13;&#10;&#13;&#10;void main(void)&#13;&#10;{&#13;&#10;    unsigned int i,j; &#13;&#10;                     &#13;&#10;    /* Initialize filter signal buffer */&#13;&#10;    for (i=0; i&lt;SN;i++)&#13;&#10;        x[i]=0;&#9;     &#13;&#10;    index=0;&#13;&#10;    &#13;&#10;    /* Processing samples using dual_MAC block FIR filter */    &#13;&#10;    j=0;&#13;&#10;    for (;;)           &#13;&#10;    {&#13;&#10;        for (i=0; i&lt;M; i++)&#13;&#10;        {&#13;&#10;            in[i]=input[j++];&#9;/* Get a buffer of samples */&#13;&#10;            if (j == 160)&#13;&#10;                j=0;&#13;&#10;        }&#13;&#10;        index=fir2macs(in,M,LP_h,L,out,x,index); /* FIR filter */&#13;&#10;    }&#13;&#10;}&#13;&#10;                                                      </TEXTAREA></p><p align=center style='text-align:center'>&nbsp;</p><p align=center style='text-align:center'>Table E5-8 FIR filter assemblyroutine that uses dual-MAC.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="fir2macs.asm">;&#13;&#10;;   fir2macs.asm - Dual-MAC Block FIR filter&#13;&#10;;&#13;&#10;;   prototype: unsigned int fir2macs(int *, unsigned int, int *, &#13;&#10;;                     unsigned int, int *, int *, unsigned int);&#9;                           &#13;&#10;;&#13;&#10;;   Entry:  arg0: AR0 - filter input buffer pointer   &#13;&#10;;           arg1: T0 - number of samples in the input buffer&#13;&#10;;           arg2: AR1 - FIR coefficients array pointer     &#13;&#10;;           arg3: T1 - FIR filter order&#13;&#10;;           arg4: AR2 - filter output buffer pointer&#13;&#10;;           arg5: AR3 - signal buffer pointer      &#13;&#10;;           arg6: AR4 - signal buffer index    &#13;&#10;;&#13;&#10;;   Return: T0 = signal buffer index&#13;&#10;;&#13;&#10;&#13;&#10;    .def    _fir2macs  &#13;&#10;    .sect    &quot;fir_code&quot;&#13;&#10;&#9;&#13;&#10;_fir2macs&#13;&#10;    pshm  ST1_55             ; Save ST1, ST2, and ST3&#13;&#10;    pshm  ST2_55&#13;&#10;    pshm  ST3_55&#13;&#10;    &#13;&#10;    or    #0x340,mmap(ST1_55); Set FRCT,SXMD,SATD&#13;&#10;    bset  SMUL               ; Set SMUL&#13;&#10;    mov   XAR1,XCDP          ; CDP as  coefficient pointer &#13;&#10;    mov   mmap(AR1),BSAC     ; Set up base address for CDP&#13;&#10;    mov   #0,CDP             ; Start from the 1st coefficient&#13;&#10;    mov   mmap(T1),BKC       ; Set the coefficient array size&#13;&#10;    mov   XAR3,XAR1          ; AR1 &amp; AR3 as signal buffer pointers&#13;&#10;    mov   mmap(AR3),BSA01    ; Set base address for AR1    &#13;&#10;    mov   mmap(AR3),BSA23    ; Set base address for AR3&#13;&#10;    add   #1,T1&#13;&#10;    mov   mmap(T1),BK03      ; Set signal buffer x[] size as L+1&#13;&#10;    mov   AR4,AR3            ; AR3 signal buffer index&#13;&#10;    mov   AR4,AR1          &#9;    &#13;&#10;    or    #0x10A,mmap(ST2_55); CDP, AR1, AR3 circular pointers&#13;&#10;    amar  *AR1+              ; AR1 delayline index+1&#13;&#10;||  sfts  T0,#-1             ; Use half of data samples &#13;&#10;    sub   #1,T0              ;   as outer repeat counter&#13;&#10;    mov   T0,BRC0            ; Outer loop couter&#9;&#13;&#10;    sub   #4,T1,T0&#13;&#10;    mov   T0,CSR             ; Inner loop counter as L/2-2&#13;&#10;||  rptblocal sample_loop-1&#13;&#10;    mov   *AR0+,*AR1         ; Put new sample to signal buffer x[n]&#13;&#10;    mov   *AR0+,*AR3         ; Put next new sample to location x[n+1]&#13;&#10;    mpy   *AR1+,*CDP+,AC0    ; The first operation&#13;&#10;::  mpy   *AR3+,*CDP+,AC1&#13;&#10;||  rpt   CSR&#13;&#10;    mac   *AR1+,*CDP+,AC0    ; The rest MAC iterations&#13;&#10;::  mac   *AR3+,*CDP+,AC1     &#13;&#10;    macr  *AR1,*CDP+,AC0&#13;&#10;::  macr  *AR3,*CDP+,AC1     ; The last MAC operation &#13;&#10;    mov   pair(hi(AC0)),dbl(*AR2+); Store two output data&#13;&#10;sample_loop&#13;&#10;&#9;&#13;&#10;    popm  ST3_55             ; Restore ST1, ST2, and ST3&#13;&#10;    popm  ST2_55&#13;&#10;    popm  ST1_55&#13;&#10;    mov   AR3,T0             ; Return signal buffer index&#13;&#10;||  ret&#13;&#10;    .end&#13;&#10;&#13;&#10;</TEXTAREA></p><p align=center style='text-align:center'>&nbsp;</p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 5C,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:l1 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Createthe project, <span style='font-family:"Courier New"'>exp5c</span> and includethe linker command file <span style='font-family:"Courier New"'>exp5.cmd</span>,the function <span style='font-family:"Courier New"'>exp5c()</span>, and theFIR filter routine <span style='font-family:"Courier New"'>fir2macs()</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:l1 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </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:l1 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </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:l1 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </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:l1 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Profilethe dual-MAC FIR filter and compare the result with Experiment 5A and 5B.</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><p><i><u><span style='font-size:7.5pt'>copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -