<?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:md="http://cnx.rice.edu/mdml/0.4" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:bib="http://bibtexml.sf.net/" id="m10621">
  <name>Multirate Filtering: Implementation on TI TMS320C55x</name>
  <metadata>
  <md:version>1.4</md:version>
  <md:created>2006/07/26 11:10:08 GMT-5</md:created>
  <md:revised>2007/01/29 16:32:38.348 US/Central</md:revised>
  <md:authorlist>
      <md:author id="tbshen">
      <md:firstname>Thomas</md:firstname>
      
      <md:surname>Shen</md:surname>
      <md:email>tbshen@uiuc.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist>
    <md:maintainer id="tbshen">
      <md:firstname>Thomas</md:firstname>
      
      <md:surname>Shen</md:surname>
      <md:email>tbshen@uiuc.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist>
    <md:keyword>banz</md:keyword>
    <md:keyword>decimation</md:keyword>
    <md:keyword>down-sample</md:keyword>
    <md:keyword>DSP</md:keyword>
    <md:keyword>interpolation</md:keyword>
    <md:keyword>multirate sampling</md:keyword>
    <md:keyword>multirate system</md:keyword>
    <md:keyword>sample-rate compressor</md:keyword>
    <md:keyword>sample-rate expander</md:keyword>
    <md:keyword>up-sample</md:keyword>
  </md:keywordlist>

  <md:abstract>You will implement a multirate system that includes three fininte impulse response filters.</md:abstract>
</metadata>






  <content>
    <section id="sec3">
      <name>Implementation</name>
      <para id="p10">Before implementing the entire system shown in <cnxn document="m10024" target="fig1">Multirate Processing:
	Introduction</cnxn>, we recommend you design a system that
	consists of a cascade of filters FIR 1 and FIR 2 without the
	sample-rate compressor or expander.  After verifying that the
	response of your two-filter system is correct, proceed to
	implement the complete multirate system and verify its total
	response.  At first, use fixed compression and expansion
	factors of
	<m:math>
	  <m:apply>
	    <m:eq/>
	    <m:ci>D</m:ci>
	    <m:ci>U</m:ci>
	    <m:cn>4</m:cn>
	  </m:apply>
	</m:math>.  After you have verified that the multirate system
        works at a fixed rate, you should modify your code so that the 
        rate can be changed easily. 
        <emphasis>You must be able to quickly change the compression and expansion  
        factors when you demo your code</emphasis>.
      </para>

      <section id="sec3a">
	<name>Compressed-rate processing</name>
	<para id="p12">
	  In order to perform the processing at the lower sample rate,
	  implement a counter in your code.  Your counter will
	  determine when the compressed-rate processing is to occur,
	  and it can also be used to determine when to insert zeros
	  into FIR 3 to implement the sample-rate expander.
	</para>

	<para id="p13">Some instructions that may be useful for implementing your
	  multirate structure are the <code>add</code> and <code>bcc</code> (branch conditional)
	  instructions.  You may also find the <code>b</code>
          (branch) instruction useful. The conditional fields that can be used with <code>bcc</code> can be found on page 1-7 of the 55x Mnemonic Instruction Set.
	</para>

      </section>
<!--
      <section id="sec3b">
	<name>Real-time rate change and MATLAB interface (Optional)</name>
	<para id="p16">A simple graphical user interface (GUI) is available (as
	  <link src="mrategui.m">mrategui.m</link>, which requires
	  <link src="rtdx_snd.m">rtdx_snd.m</link>) that sends a number
	  between 1 and 10 to the DSP via the usb port.  This can
	  be used to change the compression and expansion factor in
	  real time.
	</para>
	<para id="p18">
	  Run the GUI by typing <code>mrategui</code> at the MATLAB
	  prompt.  A figure should automatically open up with a slider
	  on it; adjusting the slider changes the compression and
	  expansion factor sent to the DSP.
	</para>

	<para id="element-186">To add RTDX capability to your program, include the <code>target.h</code> at the top of the <code>main.c</code> file. In the main function, call <code>TARGET_INITIALIZE()</code> to initialize the board for RTDX. In the while loop of of the main function, add the following code before the call to the assembly function: </para><code type="block"><![CDATA[
       RTDX_enableInput(&ichan);

       if ( !RTDX_channelBusy(&ichan)) {
            RTDX_readNB( &ichan, &rate, sizeof(rate));
       }

       RTDX_disableInput(&ichan);
]]>
</code><para id="element-634">Prior to loading the program file to the DSP board, you need to select  <code>Tools -&gt; RTDX -&gt; Configuration Control</code>. In the window that appears, make sure <code>Enable RTDX</code> is selected.</para><para id="p17">The assembly code for interacting with the serial port, provided in   
          the handout <cnxn document="m10821">Core File: Serial Port 
          Communication Between MATLAB and TI TMS320C54x</cnxn>, stores the     
          last number that the DSP has received from the computer in the
	  memory location labeled <code>rate</code>.  Therefore,
	  unless you have changed the serial portion of the given
	  code, you can find the last compression and expansion factor
	  set by the GUI in this location.  You need to modify your
	  code so that each time a new number is received on the
	  serial port, the compression and expansion factor is
	  changed.  If a "1" is received on the serial port, the
	  entire system should run at the full rate; if a "10" is
	  received, the system should discard nine samples between
	  each sample processed at the lower rate.
	</para>
	<para id="p14">
	  Note that the <code>READSER</code> and <code>WRITSER</code>
	  macros, which are used to read data from and send data to
	  the serial port, overwrite <code>AR0</code>,
	  <code>AR1</code>, <code>AR2</code>, and <code>AR3</code>
	  registers, as well as <code>BK</code> and the condition flag
	  <code>TC</code>.  You must therefore ensure that these
	  registers are not used by your code, or that you save and
	  restore their values in memory before you call the
	  <code>READSER</code> and <code>WRITSER</code> macros.  This
	  can be done using the <code>mvdm</code> and
	  <code>mvmd</code> instructions.  The serial macros set up
	  the <code>AR1</code> and <code>AR3</code> each time they are
	  called, so there is no need to change these registers before
	  the macros are called.
	</para>

	<para id="p15">
	  More detail about the <code>READSER</code> and
	  <code>WRITSER</code> macros can be found in <cnxn document="m10821">Core File: Serial Port Communication
	  Between MATLAB and TI TMS320C54x</cnxn>.
	</para>

      </section>
-->
    </section>
  </content>
</document>
