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

📄 exp4.html

📁 (Ebook-Pdf) Dsp - Real Time Digital Signal Processing (Usando Tms320-55Xx). 有书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp4.cmd">/* SPECIFY THE SYSTEM MEMORY MAP */&#13;&#10;&#13;&#10;MEMORY&#13;&#10;{&#13;&#10;   RAM   (RWIX) : origin=0100h,    length=00feffh /* Data Memory */ &#13;&#10;   RAM1  (RWIX) : origin=010000h,  length=000200h    &#13;&#10;   RAM2  (RWIX) : origin=010400h,  length=000400h       &#13;&#10;   RAM3  (RWIX) : origin=040100h,  length=040000h /* Program Memory */&#13;&#10;   ROM   (RIX)  : origin=020100h,  length=000200h /* Program Memory */&#13;&#10;   ROM1  (RIX)  : origin=020400h,  length=000200h&#13;&#10;   ROM2  (RIX)  : origin=020600h,  length=00FC00h&#13;&#10;   VECS  (RIX)  : origin=0ffff00h  length=00100h  /* Reset Vector */&#13;&#10;}&#13;&#10; &#13;&#10;/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */&#13;&#10;&#13;&#10;SECTIONS&#13;&#10;{&#13;&#10;    vectors  &gt; VECS  /* Interrupt vector table */&#13;&#10;   .text     &gt; ROM   /* CODE */  &#13;&#10;   .code     &gt; ROM1&#13;&#10;   .switch   &gt; RAM   /* SWITCH TABLE INFO */&#13;&#10;   .const    &gt; RAM   /* CONSTANT DATA */&#13;&#10;   .cinit    &gt; RAM3  /* INITIALIZATION TABLES */&#13;&#10;   .data     &gt; RAM   /* INITIALIZED DATA */ &#13;&#10;   indata    &gt; RAM1&#13;&#10;   outdata   &gt; RAM2&#13;&#10;   .bss      &gt; RAM   /* GLOBAL &amp; STATIC VARS */&#13;&#10;   .stack    &gt; RAM   /* PRIMARY SYSTEM STACK */&#13;&#10;}&#13;&#10;                                      </TEXTAREA></p><p align=center style='margin-right:36.0pt;margin-left:36.0pt;text-align:center'>&nbsp;</p><p style='margin-right:72.0pt;margin-left:72.0pt'>The C function <spanstyle='font-family:"Courier New"'>exp4a()</span> calls the assembly routines tocompute an 128-point DFT and plot the frequency domain result as its spectrum.The <a href="exp4/dft_128.asm"><span style='font-family:"Courier New"'>dft_128.asm</span></a>performs 128-point complex DFT, while <a href="exp4/mag_128.asm"><spanstyle='font-family:"Courier New"'>mag_128.asm</span></a> calculates thespectrum of the DFT result. Table E4-3 and Table E4-4 are these two assemblyroutines, respectively.</p><p style='margin-right:72.0pt;margin-left:72.0pt'>&nbsp;</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE4-3 128-point DFT routine</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="dft_128.asm">;&#13;&#10;;    DFT_128 - compute 128 points DFT&#13;&#10;;&#13;&#10;;    Entry T0: AR0: pointer to complex input sample buffer&#13;&#10;;              AR1: pointer to complex output sample buffer&#13;&#10;;    Return: None&#13;&#10;;&#13;&#10;     .def&#9;_dft_128&#13;&#10;     .ref&#9;_sine_cos&#9;&#13;&#10;&#13;&#10;N    .set 128&#13;&#10;TWOPIN    .set 0x7fff&gt;&gt;6    ; 2*PI/N, N=128&#13;&#10;          .bss Wn,2         ; Wn[0]=Wr, Wn[1]=Wi      &#13;&#10;          .bss angle,1      ; Angle for sine-cosine function&#13;&#10;     .text&#9;&#13;&#10;&#13;&#10;_dft_128&#13;&#10;    pshboth XAR5            ; Save AR5&#13;&#10;    bset    SATD&#13;&#10;    mov     #N-1,BRC0       ; Repeat counter for loop N times&#13;&#10;    mov     #N-1,BRC1       ; Repeat counter for loop N times&#13;&#10;    mov     XAR0,XAR5       ; AR5 pointer to sample buffer  &#13;&#10;    mov     XAR0,XAR3&#13;&#10;    mov     #0,T2           ; k = T2 = 0&#13;&#10;    rptb    outer_loop-1    ; for(k=0;k&lt;N;k++) {&#13;&#10;    mov     XAR3,XAR5       ; Reset x[] pointer&#13;&#10;    mov     #TWOPIN&lt;&lt;#16,AC0; hi(AC0) = 2*PI/N&#13;&#10;    mpy     T2,AC0&#13;&#10;    mov     #0,AC2          ; Xr[k] = 0&#13;&#10;    mov     #0,AC3          ; Xi[k] = 0&#13;&#10;    mov     #0,*(angle)&#9;&#13;&#10;    mov     AC0,T3          ; angle=2*PI*k/N&#13;&#10;    rptb    inner_loop-1    ; for(n=0;n&lt;N;n++) {&#13;&#10;    mov     *(angle),T0     ; T0=2*PI*k*n/N&#13;&#10;    mov     *(angle),AC0&#13;&#10;    add     T3,AC0&#13;&#10;    mov     AC0,*(angle)    ; Update angle&#13;&#10;    amov    #Wn,XAR0        ; AR0 is the pointer to Wn&#13;&#10;    call    _sine_cos       ; sine_cos(angle, Wn)&#13;&#10;    bset    SATD            ; sine_cos turn off FRCT &amp; SATD&#13;&#10;    macm40  *AR5+,*AR0,AC2  ; XR[k]+Xin[n]*Wr&#13;&#10;    macm40  *AR5-,*AR0+,AC3 ; XI[k]+Xin[n+1]*Wr&#13;&#10;    masm40  *AR5+,*AR0,AC3  ; XI[k]+Xin[n+1]*Wr-Xin[n]*Wi&#13;&#10;    macm40  *AR5+,*AR0-,AC2 ; XR[k]+Xin[n]*Wr+Xin[n+1]*Wi&#13;&#10;inner_loop                  ; } end of inner loop&#13;&#10;    mov     hi(AC2&lt;&lt;#-5),*AR1+&#13;&#10;    mov     hi(AC3&lt;&lt;#-5),*AR1+&#13;&#10;    add     #1,T2&#13;&#10;outer_loop                  ; } end of outer loop&#13;&#10;    popboth XAR5&#13;&#10;    bclr    SATD&#13;&#10;    ret&#13;&#10;    .end&#13;&#10;                     </TEXTAREA></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>&nbsp;</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE4-4 Computing spectrum</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="mag_128.asm">;&#13;&#10;;   Compute the magnitude of the input complex sample&#13;&#10;;&#13;&#10;;   Entry: AR0: input buffer pointer&#13;&#10;;          AR1: output buffer pointer&#13;&#10;;   Exit: None&#13;&#10;;&#13;&#10;    .def   _mag_128&#13;&#10;N   .set   128&#13;&#10;&#13;&#10;    .text&#13;&#10;_mag_128&#13;&#10;   bset    SATD&#13;&#10;   pshboth XAR5&#13;&#10;   mov     #N-1,BRC0       ; Set BRC0 for loop N times&#13;&#10;   mov     XAR0,XAR5&#13;&#10;   bset    FRCT&#13;&#10;   rptblocal mag_loop-1&#13;&#10;   mpym    *AR0+,*AR5+,AC0 ; Xr[i]*Xr[i]&#13;&#10;   macm    *AR0+,*AR5+,AC0 ; Xr[i]*Xr[i]+Xi[i]*Xi[i]&#13;&#10;   mov     hi(saturate(AC0)),*AR1+&#13;&#10;mag_loop&#13;&#10;   popboth XAR5&#13;&#10;   bclr    SATD&#13;&#10;   bclr    FRCT&#13;&#10;   ret&#13;&#10;   .end                                      </TEXTAREA></p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 4A,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:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Createthe project, <em>exp4a</em> and include the linker command file <spanstyle='font-family:"Courier New"'>exp4.cmd</span>, the function <spanstyle='font-family:"Courier New"'>exp4a()</span>, <span style='font-family:"Courier New"'>dft_128.asm</span>, and <span style='font-family:"Courier New"'>mag_128.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:l0 level1 lfo2;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:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Buildthe project and debug if needed.</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 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>UsingCCS to display the time domain and frequency domain samples of <spanstyle='font-family:"Courier New"'>input.dat</span> and <span style='font-family:"Courier New"'>spectrum[]</span>, the DFT result see Figure E4-1.</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 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Profilethe DFT routine and record the memory usage.</p><p style='margin-right:72.0pt;margin-left:72.0pt'>&nbsp;</p><p style='margin-right:72.0pt;margin-left:72.0pt'><img border=0 width=1024height=768 id="_x0000_i1027" src="exp4/fe4-1.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE4-1 DFT experiment results.</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></form><form><p align=center style='text-align:center'><strong><span style='font-size:13.5pt;color:blue'>Experiment 4B - Using Assembly Routines</span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>This is the first experimentthat we will conduct using only assembly routines. To do so, we will need toinitialize the system using an assembly routine called <ahref="exp4/vectors.asm"><span style='font-family:"Courier New"'>vectors.asm</span></a>.This routine will initialize the DSP system stocks, setting status registers,and start the execution upon power up or reset signals. The function <ahref="exp4/exp4b.asm"><span style='font-family:"Courier New"'>exp4b.asm</span></a>for this experiment is listed below in Table E4-5.</p><p style='margin-right:72.0pt;margin-left:72.0pt'>&nbsp;</p><p align=center style='text-align:center'>Table E4-5 List of C function forExperiment 4B</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp4b.asm">;&#9;exp4b.asm: Call dft_128 to compute DFT&#13;&#10;;&#13;&#10;N         .set 128&#13;&#10;stk_size&#9;.set&#9;0x100&#13;&#10;stack&#9;.usect &quot;.stack&quot;,stk_size&#13;&#10;sysstack&#9;.usect &quot;.stack&quot;,stk_size&#13;&#10;_Xin  &#9;.usect &quot;in_data&quot;,2*N&#13;&#10;_Xout &#9;.usect &quot;out_data&quot;,2*N&#13;&#10;_Spectrum&#9;.usect &quot;out_data&quot;,N&#13;&#10;&#13;&#10;    .sect .data&#13;&#10;input .copy input.inc&#13;&#10;&#13;&#10;    .def  start  &#13;&#10;    .def  _Xin,_Xout,_Spectrum&#13;&#10;    .ref  _dft_128,_mag_128&#9;&#13;&#10;&#13;&#10;    .sect .text&#13;&#10;&#13;&#10;start&#13;&#10;    bset  SATD            ; Set up saturation for D unit&#13;&#10;    bset  SATA            ; Set up saturation for A unit&#13;&#10;    bset  SXMD            ; Set up sign extension mode&#13;&#10;    bclr  C54CM           ; Disable C54x compatibility mode&#13;&#10;    bclr  CPL             ; Turn off compiler mode&#13;&#10;    amov  #(stack+stk_size),XSP    ; Setup DSP stack&#13;&#10;    mov   #(sysstack+stk_size),SSP ; Setup system stack&#13;&#10;    mov   #N-1,BRC0       ; Init counter for loop N times&#13;&#10;    amov  #input,XAR0     ; Input data array pointer&#13;&#10;    amov  #_Xin,XAR1      ; Xin array pointer&#13;&#10;    rptblocal complex_data-1 ; Form complex data&#13;&#10;    mov  *AR0+,*AR1+&#13;&#10;    mov  #0,*AR1+ &#13;&#10;complex_data&#13;&#10;    amov  #_Xin,XAR0      ; Xin array pointer&#13;&#10;    amov  #_Xout,XAR1     ; Xout array pointer&#13;&#10;    call  _dft_128        ; Perform 128-ponts DFT&#13;&#10;    amov  #_Xout,XAR0     ; Xout pointer&#13;&#10;    amov  #_Spectrum,XAR1 ; Spectrum array pointer&#13;&#10;    call  _mag_128        ; Computer squared-mag response&#13;&#10;&#13;&#10;here&#9;&#13;&#10;    b  here&#13;&#10;    .end                          </TEXTAREA></p><p align=center style='text-align:center'>&nbsp;</p><p align=center style='text-align:center'>Table E4-6 List of vectors.asm</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="vectors.asm">;&#13;&#10;;&#9;vectors.asm&#13;&#10;;&#13;&#10;&#9;.def&#9;rsv&#13;&#10;&#9;.ref&#9;start&#13;&#10;&#13;&#10;&#9;.sect&#9;&quot;vectors&quot;&#13;&#10;rsv&#9;.ivec&#9;start&#13;&#10;&#9;</TEXTAREA></p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 4B,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 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"'>exp4b</span> and includethe linker command file <span style='font-family:"Courier New"'>exp4.cmd</span>,the assembly routine <span style='font-family:"Courier New"'>exp4b.asm</span>,and <span style='font-family:"Courier New"'>vectors.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:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Buildthe project. Debug is needed.</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 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Use.sect, directive to allocate the data variables Xin[256], Xout[256], andSpectrum[128] at 0x8000 and 0x8800. Use .code to allocate the program routineexp4b.asm at address 0x20400.</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 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp; </span><![endif]>Testthe DFT routine and verify the memory locations.</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></form><p><i><u><span style='font-size:7.5pt'>copyright 

⌨️ 快捷键说明

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