<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5 plus MathML//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_mathml.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="m10023">
  
  <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">FIR Filtering: Exercise for TI TMS320C54x (Thai Version)</name>
  <metadata xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
  <md:version xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">2.19</md:version>
  <md:created xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">2004/04/10 13:18:04.693 GMT-5</md:created>
  <md:revised xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">2004/04/10 13:18:18.551 GMT-5</md:revised>
  <md:authorlist xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="dljones">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Douglas</md:firstname>
      <md:othername xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">L.</md:othername>
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Jones</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">dl-jones@uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="appadwed">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Swaroop</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Appadwedula</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">appadwed@uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="mjberry">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Matthew</md:firstname>
      <md:othername xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">J.</md:othername>
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Berry</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">mjberry@uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="markhaun">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Mark</md:firstname>
      <md:othername xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">A.</md:othername>
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Haun</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">markhaun@uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="jake">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Jake</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Janevitz</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">jake@janevitz.com</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="kramer">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Michael</md:firstname>
      <md:othername xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">L.</md:othername>
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Kramer</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">kramer@ifp.uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="moussa">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Dima</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Moussa</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">dmoussa@uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="dsachs">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Daniel</md:firstname>
      <md:othername xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Grobe</md:othername>
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Sachs</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">sachs@uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="bwade">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Brian</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Wade</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">bwade@uiuc.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="jpfrantz">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Patrick</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Frantz</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">jpfrantz@rice.edu</md:email>
    </md:author>
      <md:author xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="Kriengchaipruck">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Kamolchanok</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Kriengchaipruck</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Kamolchanokkrieng@hotmail.com</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
    <md:maintainer xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="jpfrantz">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Patrick</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Frantz</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">jpfrantz@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="Kriengchaipruck">
      <md:firstname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Kamolchanok</md:firstname>
      
      <md:surname xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Kriengchaipruck</md:surname>
      <md:email xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Kamolchanokkrieng@hotmail.com</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
    <md:keyword xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">assembly</md:keyword>
    <md:keyword xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">FIR filter</md:keyword>
    <md:keyword xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">DSP</md:keyword>
    <md:keyword xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">firs</md:keyword>
    <md:keyword xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">mac</md:keyword>
  </md:keywordlist>

  <md:abstract xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">You will implement band-pass finite impulse-response (FIR) filters with time-domain processing.  </md:abstract>
</metadata>




  <content xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
    <section xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="sec1">
      <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Introduction</name>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="para1a">
	ในแบบผึกหัดนี้ จะสอนวิธีการเขียน FIR filter โดยการใช้ภาษาแอสแซมบลีของ DSP  เริ่มต้นจากแอสแซมบลีพื้นฐานที่ใช้เขียน FIR filter จากไฟล์  <link xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" src="http://cnx.rice.edu/content/m10017/latest/filter.asm">filter.asm</link>.
      </para>
      <figure xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="fig1">
	<name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">filter.asm</name>
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" type="block">
	  <![CDATA[ 1	.copy "core.asm"  	; Copy in core file
	  2   					; This initializes DSP and jumps to "main"
	  3	
	  4  FIR_len .set   8			; This is an 8-tap filter.
	  5	
	  6          .sect ".data"		; Flag following as data declarations
	  7   
	  8    	    .align 16			; Align to a multiple of 16
	  9  coef					; assign label "coeff"
	  10	    .copy "coef.asm"		; Copy in coefficients
	  11
	  12	    .align 16
	  13 firstate
	  14 	    .space 16*8			; Allocate 8 words of storage for
	  15					; filter state.
	  16
	  17	    .sect ".text"		; Flag the following as program code
	  18  main
	  19      ; Initialize various pointers
	  20	    stm    #FIR_len,BK		; initialize circular buffer length
	  21	    stm    #coef,AR2    	; initialize coefficient pointer
	  22	    stm	   #firstate,AR3	; initialize state pointer
	  23	    stm    #1,AR0		; initialize AR0 for pointer increment
	  24	
	  25  loop
	  26      ; Wait for a new block of 64 samples to come in
	  27  	    WAITDATA
	  28	
	  29      ; BlockLen = the number of samples that come from WAITDATA (64)
	  30    	    stm     #BlockLen-1, BRC	; Put repeat count into repeat counter
	  31    	    rptb    endblock-1		; Repeat between here and 'endblock' 
	  32
	  33    	    ld	    *AR6,16, A		; Receive ch1 into A accumulator
	  34    	    mar     *+AR6(2)            ; Rcv data is in every other channel
	  35    	    ld      *AR6,16, B		; Receive ch2 into B accumulator
	  36    	    mar     *+AR6(2)            ; Rcv data is in every other channel
	  37    
	  38    	    ld	    A,B			; Transfer A into B for safekeeping
	  39
	  40      ; The following code executes a single FIR filter.
	  41	
	  42    	    sth     A,*AR3+%		; store current input into state buffer
	  43    	    rptz    A,(FIR_len-1)	; clear A and repeat
	  44    	    mac     *AR2+0%,*AR3+0%,A	; multiply coef. by state & accumulate
	  45    
	  46    	    rnd     A			; Round off value in 'A' to 16 bits                            
	  47    
	  48     ; end of FIR filter code. Output is in the high part of 'A.'
	  49
	  50    	    sth     A, *AR7+		; Store filter output (from A) into ch1
	  51    	    sth     B, *AR7+		; Store saved input (from B) into ch2
	  52    
	  53    	    sth     B, *AR7+		; Store saved input to ch3...ch6 also
	  54    	    sth     B, *AR7+		; ch4
	  55    	    sth     B, *AR7+		; ch5 
	  56    	    sth     B, *AR7+		; ch6
	  57   
	  58  endblock:
	  59      b loop]]>
	</code>
      </figure>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p1">
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">filter.asm</code> จะทำการใช้ FIR filter กับอินพุต channel ที่ 1 แล้วทำการส่งผลลัพธ์ที่ได้ไปยัง channel ที่ 1 พร้อมกับส่ง อินพุตที่ไปยัง channel ที่ 2
      </para>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p2">
	ลำดับแรก  สร้าง workin directory ของคุณขึ้นที่ network  drive สำหรับไฟล์ที่จะใช้ในแบบฝึกหัดนี้ จากนั้นทำการ copy <link xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" src="http://cnx.rice.edu/content/m10017/latest/filter.asm">filter.asm</link>
	และ  <link xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" src="http://cnx.rice.edu/content/m10017/latest/core.asm">core.asm</link>
	ไปไว้ใน directory ที่สร้างขึ้น เสร็จแล้วให้ใช้ MATLAB สร้าง  20-tap FIR
	filter  2 อัน filter ตัวแรก ควรผ่านสัญญาณที่มีความถี่ ตั้งแต่  4 kHz ถึง 8 kHz; ส่วน filter ตัวที่สอง ให้ ผ่านสัญญาณความถี่ 8 kHz ถึง 12 kHz 
	สำหรับ filter ทั้งสอตัว ให้ใช้ 1 kHz transition band ที่ทุกริมของ filter passband ในการสร้าง filter พวกนี้ ควรจะแปลง band edge ให้เป็น
	สัญญาณดิจิตอล โดยเทียบจาก 44.1 kHz
	sample rate ของระบบ จากนั้นให้ใช้คำสั่ง MATLAB
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">remez</code> ในการสร้าง filter; อาจลองพิมพ์
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">help remez</code> สำหรับ รายละเอียดของการใช้คำสั่ง  และใช้คำสั่ง
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">save_coef</code>save filter แต่ละตัวคนละไฟล์ (ตรวจดูก่อน save ว่าได้ทำการกลับเวคเตอร์ ของ filter coef เรียบร้อยแล้ว)
	ทำการ save filter ในรูปของ MATLAB matrix ด้วย เพราะคุณจะต้องใช้มันภายหลังในการสร้าง test เวคเตอร์
                     สารมารถทำได้โดย ใช้คำสั่ง  	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">save</code> ใน MATLAB
	เมื่อเสร็จเรียบร้อยแล้ว ให้ใช้คำสั่ง 	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">freqz</code> 
	ในการสร้าง frequency response ให้แต่ละ filter
      </para>
    </section>
    <section xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="sec2">
      <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Part 1: Single-Channel FIR Filter</name>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p3">
	สำหรับตอนนี้คุณจะทำการ implement แค่ filter ที่ใช้ 4 kHz ถึง 8
	kHz passband เท่านั้น. แก้ไข  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">filter.asm</code> เพื่อใช้ coefficient สำหรับ filter ตัวนี้
      </para>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p4">
	อย่างแรก เราจะใช้ FIR filter ขนาด 20 ไม่ใช่ 8 ในแบบฝึกหัดนี้
	ฉะนั้นคุณจะต้องเปลี่ยน  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">FIR_len</code> เป็น
	20. <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">FIR_len</code> โดยใช้ directive  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.set</code>
	ซึ่งสามารถ set ค่า ได้โดย assign ค่าตัวเลขให้  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">FIR_len .set 20</code>.
      </para>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p5">
	ขั้นที่สอง, คุณจะต้องแน่ใจว่า  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.copy</code>
	directive copy ค่า coefficients ที่ถูกต้อง. เปลี่ยนชื่อไฟล์ เป็นชื่อไฟล์ที่เก็บค่า
	ของ coefficients ที่ใช้สำหรับ filter ตัวแรก
      </para>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p6">
	จากนั้นให้ทำการแก้ไข <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.align</code> และ
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.space</code> directives ต่างๆ ตามความเหมาะสม.  TI
	TMS320C54x DSP ต้องใช้ circular buffers, เพื่อใช้สำหรับ 
	 FIR filter coefficient และ state buffers, ซึ่งถูก set ให้ตรงกัน
	โดยให้ address เริ่มต้น เป็นค่ายกำลังสอง
	so that they begin at an address that is a multiple of a power
	of two greater than the length of the buffer. Since you are
	using a 20-tap filter (ซึ่งใช้ 20-element state และ
	coefficient บัฟเฟอร์), the next greater power of two is 32.
	ฉะนั้นคุณจะต้องทำการตั้งค่า address ของทั้ง state และ coefficient
	บัฟเฟอร์ เป็นจำนวนเท่าของ 32
	(16-element บัฟเฟอร์จะต้องถูกตั้งค่าให้เป็นจำนวนเท่าของ 32 เช่นกัน)
	ซึ่งสามารถทำได้โดยใช้คำสั่ง <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.align</code> นอกจากนี้หน่วยความจำยัง
	ต้องถูกจองไว้ให้ state บัฟเฟอร์ด้วย ทำได้ โดยใช้ directive
	 <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.space</code> ซึ่งจะรับจำนวน  <emphasis xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">bits</emphasis> 
	ของเนื้อที่ทที่ต้องการ . ฉะนั้นถ้าต้องการ เนื้อที่ 20 word จะต้องใช้
	directive <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.space 16*20</code> ดังตัวอย่างข้างใต้
      </para>
      <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" type="block">
	<![CDATA[1         .align 32             % Align to a multiple of 32
	2  coef   .copy  "filter1.asm"  % Copy FIR filter coefficients
	3
	4         .align 32             % Align to a multiple of 32
	5  state  .space 16*20          % Allocate 20 words of data space]]>
      </code>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p7">
	แก้ไข code, ตั้งค่า  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">PMST</code> เป็น
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">0xFFE0</code>, reset  DSP, แล้ว run.  ตรวจดูว่า ค่าความถี่ที่ตอกลับ
	มานั้นถูกต้อง หลังจากที่แน่ใจว่า code ทำงานได้ถูกต้องแล้ว ให้เริ่มขั้นต่อไป
      </para>
    </section>
    <section xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="sec3">
      <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Part 2: Dual-Channel FIR Filters</name>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p9">
	ขั้นแรก, ให้สร้าง copy ของ  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">filter.asm</code> ที่ถูกทำการแก้ไข
	เรียบร้อยแล้ว จากไฟล์ <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" target="sec2">Part 1</cnxn>. 
	ใช้ไฟล์นี้ในการทำงาน อย่าทำการแก้ไข filter ที่ใช้ก่อนหน้านี้ เพราะจะมี
	การใช้ filter ตัวเดิมอีกในภายหลัง
      </para>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p10">
	จากนั้น, ทำการแก้ไข code เพื่อที่จะทำการส่ง output ไปที่ filter ตัวแรก
	 (ด้วย passband  4 kHz ถึง 8 kHz ) ที่ output channel 1 แล้วoutput ที่ไม่ได้ผ่าน
 	filter ไปยัง output channel 2, ส่ง output จาก filter ตัวที่สอง
	(ด้วย passband 8 kHz ถึง12 kHz ) ไปยัง output channel 3. 
	เพื่อนที่จะทำงานได้ดังที่กล่าว คุณจะต้องใช้  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.align</code>  และ
	 <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.copy</code> คำสั่งในการ load ชุดของ coefficients ชุดที่สอง
	ไปยัง data	memory.  นอกจากนี้จะต้องเพิ่มคำสั่ง เพื่อ initialize ค่าของ
	pointer ให้ชี้ไปยัง coefficients ชุดที่สอง และคำนวณค่าให้ filter ตัวที่สอง
      </para>
      <exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="new0">
	<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">
	  <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Challenge Problem</name> 
	  <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="new1"> 
	    คุณสามารถ implement dual-channel system โดยไม่ใช้ auxiliary registers 
	   <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">AR4</code> และ   <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">AR5</code> ได้หรือไม่ ?  
	ทำไมมันถึงยากกว่าปกติ  ?  การเปลี่ยนชื่อ   <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">AR4</code> และ <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">AR5</code> 
	โดยใช้  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">.asg</code> ถือว่าไม่นับ!
	  </para>
	</problem>
      </exercise>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p11">
	การใช้เทคนิคที่กล่าวถึงใน <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" document="m10017">DSP
	Development Environment: Introductory Exercise for TI
	TMS320C54x</cnxn>, เพื่อนสร้าง test vector และ output ที่ต้องการ
	ที่เหมาะสมใน MATLAB. และการใช้ test-vector core
	file ที่อ้างอิงจาก <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" document="m10017">DSP
	Development Environment: Introductory Exercise for TI
	TMS320C54x</cnxn>, หาผลลัพธ์จากระบบโดยการใช้ test vector นี้
	ใน MATLAB ให้ทำการสร้างกราฟจากผลลัพธ์จริงและผลัพธ์ที่คาดว่าน่าจะเกิด
	จากทั้งสอง filter และ ผลต่างจากผลลัพธ์ทั้งสอง ทำไมผลลัพธ์ที่เกิดจาก
	DSP ถึงไม่เท่ากับผลลัพธ์ที่จาก MATLAB ?
      </para>
    </section>
    <section xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="sec5">
      <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Part 3: Alternative Single-Channel FIR Implementation</name>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p12">
	อีกทางเลือกหนึ่งสำหรับการ  implementing symmetric FIR filters
	โดยใช้คำสั่ง  <term xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/"><code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">firs</code></term> instruction.  แก้ไข
	code จาก <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" target="sec2">Part 1</cnxn> เพื่อ implement
	filter ที่ใช้ passband 4 kHz to 8 kHz โดยใช้ <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">firs</code>.
      </para>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p13">
	ข้อแตกต่างสองประการ ในการ  implementation ระหว่าง code จาก 
	 <cnxn xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" target="sec2">Part 1</cnxn> และ code ที่คุณจะต้องเขียน 
	สำหรับส่วนนี้ คือ (1) the <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">firs</code> คำสั่งนี้จะทำให้ coefficients 
	ถูก locate ในส่วนของ program memory แทนที่จะใช้ 
	data memory, และ (2) <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">firs</code> จะทำให้ states
	ถูกแยกออกเป็น สอง circular buffer.  อ้างอิงจาก  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">firs</code>
	คำสั่งบน <cite xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">หน้า 4-59</cite> ใน  <cite xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" src="http://www-s.ti.com/sc/psheets/spru172c/spru172c.pdf">
	คู่มือ Mnemonic Instruction Set</cite>  ซึ่งมีทั้งคำอธิบายและตัวอย่างการใช้
	 <cite xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">หน้า 4-5 จนถึง 4-8</cite> ของ  <cite xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" src="http://www-s.ti.com/sc/psheets/spru173/spru173.pdf">Applications
	Guide</cite> ถ้าหากต้องการข้อมูลเพิ่มเติม (<cite xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">Volumes 2 and
	4</cite> respectively of the <cite xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">TMS320C54x DSP Reference
	Set</cite>).
      </para>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p14">
	<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">AR0</code> ต้องถูกตั้งค่าเป็น -1 เพื่อที่จะให้โปรแกรมทำงานได้ถูกต้อง
	ทำไม? <note xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" type="Note"><code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">COEFF</code> เป็นตัวระบุว่า coeffients ตัวไหนที่จะถูกโหลดเข้า
	ไปใน program memory.  อ้างอิงจาก คำอธิบายของ
	  <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">firs</code> สำหรับข้อมูลเพิ่มเติม).</note>
      </para>
      <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" type="block">
	
	<![CDATA[ 
	1	mvdd	*AR2,*AR3+0%		; write x(-N/2) over x(-N)
	2	sth	A,*AR2			; write x(0) over x(-N/2)
	3	add	*AR2+0%,*AR3+0%,A 	; add x(0) and x(-(N-1))
	4					;   (prepare for first multiply)
	5
	6	rptz	B,#(FIR_len/2-1)  	  
	7	firs	*AR2+0%,*AR3+0%,COEFF
	8	mar	??????? 		; Fill in these two instructions
	9	mar	???????			; They modify AR2 and AR3.
	10
	11					; note that the result is now in the
	12					;  B accumulator]]>
      </code>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p15">
	เนื่องจากในตอนนี้  states และ coefficients จะถูกนำมาใช้ต่างจาก FIR คราวก่อน, 
	ฉะนั้นจะต้องทำการแก้ไข ค่าตั้งต้นของ  pointer 
      </para>
      <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" type="block">
	<![CDATA[
	1	stm	#(FIR_len/2),BK		; initialize circular buffer length
	2	stm	#firstate_,AR2		; initialize location containing first 
	3					;   half of states
	4
	5	stm	#-1,AR0			; Initialize AR0 to -1
	6
	7	stm	#firstate2_,AR3	        ; initialize location containing last half
	]]>
      </code>
      <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="p16">
	ใช้ test-vector ใน ไฟล์หลัก เพื่อหาผลลัพธ์จากระบบ และใช้ 
	test-vector ตัวเดียวกัน ทดสอบกับ two-filter system.
	เปรียบเทียบผลลัพธ์ของ filter นี้ กับ filter ที่ถูก implement 
	โดยใช้  คำสั่ง<code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/">mac</code>  ผลลัพธ์เหมือนกันหรือไม่?
	ทำไมเหมือนหรือทำไมไม่เหมือน?  ตรวจให้แน่ใจว่าผลลัพธ์ถูกส่งไป
	ที่ channel 1, และ ผลลัพธ์ที่ไม่ได้ ถูก filter ไปที่ output channel 2.
      </para>
    </section>
  </content>
</document>
