<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE document PUBLIC "-//CNX//DTD CNXML 0.5//EN" "http://cnx.rice.edu/cnxml/0.5/DTD/cnxml_plain.dtd">
<document xmlns="http://cnx.rice.edu/cnxml" xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="None">
  <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Lab 8: DMA + RS232</name>
  <metadata xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
  <md:version xmlns:bib="http://bibtexml.sf.net/">1.2</md:version>
  <md:created xmlns:bib="http://bibtexml.sf.net/">2005/03/30 00:36:14 US/Central</md:created>
  <md:revised xmlns:bib="http://bibtexml.sf.net/">2005/06/03 16:36:15.361 GMT-5</md:revised>
  <md:authorlist xmlns:bib="http://bibtexml.sf.net/">
      <md:author xmlns:bib="http://bibtexml.sf.net/" id="adrianv">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Adrian</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Valenzuela</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">adrianv@rice.edu</md:email>
    </md:author>
  </md:authorlist>

  <md:maintainerlist xmlns:bib="http://bibtexml.sf.net/">
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="adrianv">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Adrian</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Valenzuela</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">adrianv@rice.edu</md:email>
    </md:maintainer>
    <md:maintainer xmlns:bib="http://bibtexml.sf.net/" id="jpfrantz">
      <md:firstname xmlns:bib="http://bibtexml.sf.net/">Patrick</md:firstname>
      
      <md:surname xmlns:bib="http://bibtexml.sf.net/">Frantz</md:surname>
      <md:email xmlns:bib="http://bibtexml.sf.net/">jpfrantz@rice.edu</md:email>
    </md:maintainer>
  </md:maintainerlist>
  
  <md:keywordlist xmlns:bib="http://bibtexml.sf.net/">
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">dma</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">elec226</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">lab 8</md:keyword>
    <md:keyword xmlns:bib="http://bibtexml.sf.net/">rs232</md:keyword>
  </md:keywordlist>

  <md:abstract xmlns:bib="http://bibtexml.sf.net/">Lab 8 deals with the benifits of using DMA and using RS232 as a communication protocol.</md:abstract>
</metadata>

  <content xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">


        <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p6">
          Direct memory access is a system to transfer data between peripheral modules and memory without using processor instructions.  While its operation does occupy the memory bus, far fewer instructions require CPU interaction.  This allows the CPU to work on other tasks simultaneously, or it may be be put into a low power mode.</para>
 
      <exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="exercise5_3">
        <problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
         <name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">DMA Powered Voltmeter</name>
          <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p8">
             The DMA module allows you to automatically move data between memory locations.  This will also allow us to automate much of your program's execution.
          </para>
          <para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p9"><list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="l1a" type="enumerated">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">Set up the DMA module to automatically transfer the data from the ADC to the DAC.   Transfer the input from the ADC1 to DAC0 and ADC0 to DAC1. Sampling should be interrupt enabled.</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/"> Measure the peak-to-peak amplitude of the input signal to  ADC0 using the processor.  Units are irrelevant.  Display the amplitude on the seven segment display.   You should have at least 4 different possible levels.</item>
         </list>  </para>
        </problem>
      </exercise> 
<exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="e2">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<name xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">RS232</name>
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p2">
 We will configure the serial port (RS232) to transmit data. Just like before create a new project and do the following: disable the watchdog timer, and initialize the master clock and i2c. This should now be standard for all new projects. To set up the UART to use RS232 we must set the following registers:
<list xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="l1">
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/"> Reset UICTL (on its own line of code)</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/"> Set the character length to 8-bits</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/"> Set U1TCTL to enable ACLK as the BRCLK clock.</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">  The baud rate should have the following settings: <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">U1BR0 = 0x7c;</code> and <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">U1BR1 = 0x01;</code> This will set the baud rate at 19,200 bits per second.</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/"> Set ME2 to enable both transmit and receive.</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">  Enable UART_TX and UART_RX on the msp (Hint: use P3SEL)</item>
<item xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">  Set UART_TX as an output pin.</item>
</list>
</para>
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p3">
To transmit data, check if the UTXIFG1 flag is set in UTXIFG1. Once the flag is set you may write directly to TXBUF1, and that data will be transmitted. Now, come up with an array of ASCII characters in hexadecimal notation, and load each character in the TXBUF1 one at a time. Don't for get to add a new line character, <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">/n</code>, at the end of your message.
</para>
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p4">
To test your project open up HyperTerminal, and set the correct baud rate (19200). All other default settings should be fine. If you correctly configured the UART then you should see your message in the terminal. 
</para>
</problem>
</exercise> 
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="element-127"> Once you have verified that you can transmit data to the serial port, load the <code xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">TXBUF1</code> via DMA.  You may trigger the DMA any way you wish.  This will eliminate most of the work that the processor has to do.</para><exercise xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="e3">
<problem xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/">
<para xmlns:md="http://cnx.rice.edu/mdml/0.4" xmlns:bib="http://bibtexml.sf.net/" id="p5">
Modify the first problem so that you input something into ADC0 and DMA the samples to the serial port.  Come up with some way for a computer to read those values, HyperTerminal or otherwise. 
</para>
</problem>
</exercise>
  </content>
  
</document>
