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

📄 exp6.html

📁 (Ebook-Pdf) Dsp - Real Time Digital Signal Processing (Usando Tms320-55Xx). 有书
💻 HTML
📖 第 1 页 / 共 4 页
字号:
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Createthe project, <span style='font-family:"Courier New"'>exp6c</span> and includethe linker command file <span style='font-family:"Courier New"'>exp6.cmd</span>,the C function <span style='font-family:"Courier New"'>exp6c.c</span>,<spanstyle='font-family:"Courier New"'> iir_i2.c</span>,<span style='font-family:"Courier New"'> signal_gen2.c</span>, and the assembly routine <spanstyle='font-family:"Courier New"'>sine.asm</span>. The C routine <spanstyle='font-family:"Courier New"'>iir_i2.c</span> uses unsigned integer fortrip counters and replaced the MOD operation with AND operation for thedelay-line buffer.</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:l0 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 the C function <spanstyle='font-family:"Courier New"'>main()</span>initialization and build theproject <span style='font-family:"Courier New"'>exp6c</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:l0 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Relocatethe C program and data variables into different named SARAM and DARAM sectionsdefined by the linker command files.</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:l0 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Enable<span style='font-family:"Courier New"'>&#8211;o3</span> and <span style='font-family:"Courier New"'>&#8211;mp</span> options to rebuild 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:l0 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Enablebreak point at the statement <span style='font-family:"Courier New"'>for(;;)</span>ofthe <span style='font-family:"Courier New"'>main()</span> function and use CCSgraphic function to view the 16-bit integer output samples in the buffer <spanstyle='font-family:"Courier New"'>out[]</span>, set data length to 128 forviewing one block data a time. Animate the filtering process and observe thefilter output as a clean sine wave of 800 Hz.</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:l0 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>6.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Profilethe IIR filter <span style='font-family:"Courier New"'>iir_i2()</span> andcompare the result with those obtained in Experiment 6B.</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 6D - IIR Filter Assembly Language Implementation </span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>The hand-coded assembly codefor the TMS320C55x DSP processor will give us the best performance although itgenerally takes longer time to write and debug. We can write an efficient IIRfilter assembly routine that uses only seven DSP cycles to compute each output.Table E6-10 and Table E6-11 give the function <a href="exp6/exp6d.c"><spanstyle='font-family:"Courier New"'>exp6d.c</span></a> and modified IIR function <ahref="exp6/iirform2.asm"><span style='font-family:"Courier New"'>iirform2.asm</span></a>,respectively.</p><p style='margin-right:36.0pt;margin-left:36.0pt'>&nbsp;</p><p align=center style='text-align:center'>Table E6-10 List of C function forExperiment 6D.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp6d.c">/* &#13;&#10;   exp6d.c - Direct form II - IIR function in TMS320C55x assembly&#13;&#10;*/                           &#13;&#10;&#13;&#10;#define M       128    /* Number of samples per block */&#13;&#10;#define Ns&#9;&#9;2      /* Number od 2nd order sections */&#13;&#10;&#13;&#10;#pragma DATA_SECTION(C, &quot;iir_coef&quot;);&#13;&#10;#pragma DATA_SECTION(w, &quot;iir_data&quot;); &#13;&#10;#pragma DATA_SECTION(out, &quot;iir_out&quot;); &#13;&#10;#pragma DATA_SECTION(in, &quot;iir_in&quot;); &#13;&#10;#pragma CODE_SECTION(main, &quot;iir_code&quot;);&#13;&#10;&#13;&#10;/* &#13;&#10;   exp6d.c - Direct form II - IIR function in TMS320C55x assembly&#13;&#10;*/                           &#13;&#10;&#13;&#10;#define M       128    /* Number of samples per block */&#13;&#10;#define Ns      2      /* Number od 2nd order sections */&#13;&#10;&#13;&#10;#pragma DATA_SECTION(C, &quot;iir_coef&quot;);&#13;&#10;#pragma DATA_SECTION(w, &quot;iir_data&quot;); &#13;&#10;#pragma DATA_SECTION(out, &quot;iir_out&quot;); &#13;&#10;#pragma DATA_SECTION(in, &quot;iir_in&quot;); &#13;&#10;#pragma CODE_SECTION(main, &quot;iir_code&quot;);&#13;&#10;&#13;&#10;/* Low-pass IIR filter coefficients in Q14 format */&#13;&#10;int C[Ns*5]={ /* i=section number */&#13;&#10;              /* A[i][1],A[i][2],B[i][2],B[i][0],B[i][1] */&#13;&#10;                  -14187,   3505,   1624,   1624,   3249,&#13;&#10;                  -18430,   9454,   1624,   1624,   3249};&#13;&#10;/* IIR filter delay line:&#13;&#10;w[]=w[i][n-1],w[i+1][n-1],...,w[i][n-2],w[i+1][n-2],... */ &#9;   &#13;&#10;int w[Ns*2];&#13;&#10;&#13;&#10;int out[M];  &#13;&#10;int in[M];  &#13;&#10;&#13;&#10;/* IIR filter function */&#13;&#10;extern void iirform2(int*, unsigned int, int *, int *, unsigned int , int *);&#13;&#10;&#13;&#10;/* Software signal generator */&#13;&#10;extern void signal_gen2(int *, unsigned int, int);&#13;&#10;&#13;&#10;&#13;&#10;void main(void)&#13;&#10;{&#13;&#10;    unsigned int i;&#13;&#10;    int *ptr=&amp;w[0];&#13;&#10;    &#13;&#10;    /* Initialize IIR filter delay line and signal generator */&#13;&#10;    for (i=Ns*2; i&gt;0; i--)&#13;&#10;        *ptr++ = 0; &#13;&#10;    signal_gen2(in,M,1); &#13;&#10;        &#13;&#10;    /* IIR filter experiment start */   &#13;&#10;    for (;;)           &#13;&#10;    {&#13;&#10;        signal_gen2(in,M,0);        /* Generate a block of samples */&#13;&#10;        iirform2(in,M,out,C,Ns,w);  /* Filter a block of samples */                          &#13;&#10;    }&#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 E6-11 Modified IIR filterfunction.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="iirform2.asm">;&#13;&#10;;   iirform2.asm  IIR direct form II (biquads) IIR filter&#13;&#10;;&#9;  &#13;&#10;;   Prototype: void iirform2(int *, unsigned int, int *, int *, unsigned int, int *);&#13;&#10;;                           &#13;&#10;;   Entry:  arg0: AR0-filter input sample buffer pointer   &#13;&#10;;           arg1: T0-number of samples in input buffer&#13;&#10;;           arg2: AR2-output sample buffer pointer&#13;&#10;;           arg3: AR1-IIR coefficients array pointer     &#13;&#10;;           arg4: T1-number of biquads IIR  sections&#13;&#10;;           arg5: AR3-delayline pointer  &#13;&#10;;&#13;&#10;;&#13;&#10;;   Direct form II - IIR filter (the ith sections):&#13;&#10;;   d(n) = x(n) - ai1*d(n-1)-ai2*d(n-2)&#13;&#10;;   y(n) = bi0*d(n) + bi1*d(n-1) + bi2*d(n-2)&#13;&#10;;&#13;&#10;;   Memory arrangement and initialization: (1,2,...i,..,Ns)&#13;&#10;;   tempbuf[2*Ns] coefficient[5*Ns]&#13;&#10;;   AR3 -&gt; w1i       AR7 -&gt; a1i&#13;&#10;;          w1j              a2i&#13;&#10;;           :               b2i&#13;&#10;;          w2i              b0i&#13;&#10;;          w2j              b1i&#13;&#10;;           :                :      &#13;&#10;;&#13;&#10;;   Scale: Coefficient is in Q14 format            &#13;&#10;;   The filter result is scaled up to compensate the Q14 coefficient                              &#13;&#10;;&#13;&#10;      .global _iirform2&#13;&#10;      .sect   &quot;iir_code&quot; &#13;&#10;&#9;&#13;&#10;_iirform2&#13;&#10;      pshm  ST1_55                 ; Save ST1, ST2, and ST3&#13;&#10;      pshm  ST2_55&#13;&#10;      pshm  ST3_55&#13;&#10;      psh   T3                     ; Save T3 &#9;       &#13;&#10;      pshboth XAR7                 ; Save AR7&#13;&#10;&#13;&#10;      or    #0x340,mmap(ST1_55)    ; Set FRCT,SXMD,SATD&#13;&#10;      bset  SMUL                   ; Set SMUL&#13;&#10;      sub   #1,T0                  ; Number of samples - 1&#13;&#10;      mov   T0,BRC0                ; Set up outer loop counter&#13;&#10;      sub   #1,T1,T0               ; Number of sections -1&#9;&#13;&#10;      mov   T0,BRC1                ; Set up inner loop counter&#13;&#10;&#9;&#13;&#10;      mov   T1,T0                  ; Set up circular buffer sizes&#13;&#10;      sfts  T0,#1          &#13;&#10;      mov   mmap(T0),BK03          ; BK03=2*number of sections&#13;&#10;      sfts  T0,#1&#9;&#9;&#9;&#9;&#13;&#10;      add   T1,T0                                      &#13;&#10;      mov   mmap(T0),BK47          ; BK47=5*number of sections&#13;&#10;      mov   mmap(AR3),BSA23        ; Initial delay buffer base &#13;&#10;      mov   mmap(AR2),BSA67        ; Initial coefficient base &#13;&#10;      amov  #0,AR3                 ; Initial delay buffer entry &#13;&#10;      amov  #0,AR7                 ; Initial coefficient entry &#13;&#10;      or    #0x88,mmap(ST2_55)&#13;&#10;      mov   #1,T0                  ; Used for shift left&#13;&#10;||    rptblocal sample_loop-1&#9;     ; Start IIR filter loop  &#13;&#10;      mov   *AR0+ &lt;&lt;#14,AC0        ; AC0 = x(n)/2 (i.e. Q14)&#13;&#10;||    rptblocal filter_loop-1      ; Loop for each section&#13;&#10;      masm  *(AR3+T1),*AR7+,AC0    ; AC0-=ai1*di(n-1)     &#13;&#10;      masm  T3=*AR3,*AR7+,AC0&#9;     ; AC0-=ai2*di(n-2)     &#13;&#10;      mov   rnd(hi(AC0&lt;&lt;T0)),*AR3  ; di(n-2)=di(n) &#13;&#10;||    mpym  *AR7+,T3,AC0           ; AC0+=bi2*di(n-2) &#13;&#10;      macm  *(AR3+T1),*AR7+,AC0    ; AC0+=bi0*di(n-1)                 &#13;&#10;      macm  *AR3+,*AR7+,AC0        ; AC0+=bi1*di(n) &#13;&#10;filter_loop&#13;&#10;      mov   rnd(hi(AC0&lt;&lt;#2)),*AR1+ ; Store result in Q15&#13;&#10;sample_loop&#13;&#10;&#13;&#10;      popboth XAR7                 ; Restore AR7&#13;&#10;      pop   T3                     ; Restore T3&#13;&#10;      popm  ST3_55                 ; Restore ST1, ST2, and ST3&#13;&#10;      popm  ST2_55&#13;&#10;      popm  ST1_55&#13;&#10;      ret&#13;&#10;&#9;&#13;&#10;      .end</TEXTAREA></p><p align=center style='text-align:center'>&nbsp;</p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 6D,following these steps:</p></form><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 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"'>exp6d</span> and includethe linker command file <span style='font-family:"Courier New"'>exp6.cmd</span>,the C function <i><span style='font-family:"Courier New"'>exp6d.c</span></i>, <i><spanstyle='font-family:"Courier New"'>signal_gen2.c</span></i>, the assemblyroutine <span style='font-family:"Courier New"'>sine.asm</span>, and the IIRfilter assembly routine <span style='font-family:"Courier New"'>iirform2.asm</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 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 the C function <spanstyle='font-family:"Courier New"'>main()</span>initialization and build theproject <span style='font-family:"Courier New"'>exp6d</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 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Enablebreak point at the statement <span style='font-family:"Courier New"'>for(;;)</span>ofthe <span style='font-family:"Courier New"'>main()</span> function and use CCSgraphic function to view the 16-bit integer output samples in the buffer <spanstyle='font-family:"Courier New"'>out[]</span>, set data length to 128 forviewing one block data a time. Animate the filtering process and observe thefilter output as a clean sine wave of 800 Hz.</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 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Profilethe IIR filter <span style='font-family:"Courier New"'>iirform2()</span> andcompare the profile result with those obtained in Experiment 6B and 6C.</p><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 + -