<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6294703911188142008</atom:id><lastBuildDate>Tue, 21 Feb 2012 00:11:28 +0000</lastBuildDate><category>arduino</category><category>fpga</category><category>radio</category><category>personal</category><category>tutorial</category><category>eagle</category><category>gp2d12</category><category>launchpad</category><category>project</category><category>syntax highlighter</category><category>morse</category><category>review</category><category>beetlebot</category><category>msp430</category><category>vhdl</category><category>electronics</category><title>enrico::garante</title><description>electronics, computers and science...</description><link>http://www.egarante.net/</link><managingEditor>noreply@blogger.com (Enrico Garante)</managingEditor><generator>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/egarante" /><feedburner:info uri="egarante" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/3.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by-nc-sa/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-9029627553924387801</guid><pubDate>Wed, 18 Jan 2012 00:09:00 +0000</pubDate><atom:updated>2012-01-18T20:12:24.397+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">fpga</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">vhdl</category><title>Learning VHDL - Basics</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/J9Ynz5FdlFOWwEwDILbjrGWwFVM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J9Ynz5FdlFOWwEwDILbjrGWwFVM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/J9Ynz5FdlFOWwEwDILbjrGWwFVM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/J9Ynz5FdlFOWwEwDILbjrGWwFVM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;Today I start a new series of tutorials &amp;nbsp;focused of &lt;b&gt;FPGA &lt;/b&gt;and &lt;b&gt;VHDL &lt;/b&gt;programming.&lt;br /&gt;
Since FPGA are becoming more accessible to the hobbyist, learning how to use them can be really useful for certain applications; moreover, engineers that are able to code in VHDL/Verilog are always requested on the job market.&lt;br /&gt;
&lt;br /&gt;
In this tutorial I'll cover the basics of &lt;b&gt;Xilinx ISE&lt;/b&gt; and VHDL.&lt;br /&gt;
I'll base my code on the &lt;b&gt;&lt;a href="http://www.digilentinc.com/Products/Detail.cfm?Prod=BASYS2" target="_blank"&gt;Basys2&lt;/a&gt; &lt;/b&gt;board from Digilent: it is really cheap (especially for students) and has a lot of features on board.&lt;br /&gt;
However, in this tutorial we'll only simulate our code with ISim, for the real applications check back soon!&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://www.digilentinc.com/Data/Products/BASYS2/BASYS2-top-400.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="245" src="http://www.digilentinc.com/Data/Products/BASYS2/BASYS2-top-400.jpg" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Digilent's Basys2 board&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
So, let's start this thing. First I'll explain our test code, then I'll show you how to compile and simulate it in ISE Webpack.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;VHDL &lt;/b&gt;is the acronym for &lt;i&gt;VHSIC Hardware Description Language&lt;/i&gt; (where VHSIC stands for&lt;i&gt; Very High Speed Integrated Circuits&lt;/i&gt;). It becomes an IEEE standard in 1987 and it is the most used language (along with Verilog) to describe digital electronic systems.&lt;br /&gt;
&lt;br /&gt;
VHDL seems just like any other computer language, as it uses many common construct like if, then, else. But the main difference is that it is a &lt;a href="http://en.wikipedia.org/wiki/Dataflow_programming" target="_blank"&gt;dataflow language&lt;/a&gt;: this means that it describes how several blocks of code are connected and executed at the same time.&lt;br /&gt;
Each block of code describes a digital subsystem, with inputs and outputs.&lt;br /&gt;
&lt;br /&gt;
VHDL programming consists of two phases:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;ENTITY&lt;/b&gt; description: we state how the block is seen from outside (ports, buses, configurations...)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;ARCHITECTURE&lt;/b&gt;&amp;nbsp;description: we describe how the block works internally.&lt;/li&gt;
&lt;/ul&gt;
Enough theory already, let's see some code...&lt;br /&gt;
We start referencing the main VHDL library and using the&amp;nbsp;STD_LOGIC_1164.ALL package, that contains several datatypes, logic operations and functions.&amp;nbsp;&lt;span style="background-color: white;"&gt;This should probably be included in every entity you create.&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;Note that every instruction is terminated with the semicolon. To create a comment just use the # character.&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class="brush: vhdl"&gt;library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
#This is a comment.&lt;/pre&gt;
&lt;br /&gt;
Then we define our "black box" with the "&lt;i&gt;entity"&amp;nbsp;&lt;/i&gt;statement followed by its name and the keyword&lt;i&gt;&amp;nbsp;"is".&lt;/i&gt;&lt;br /&gt;
The next statement &lt;i&gt;"Port" &lt;/i&gt;describes how many "wires" are exposed to the outside; the list is composed this way: &lt;i&gt;name : direction type. &lt;/i&gt;The last element of the list isn't terminated with the semicolon, but we need to terminate the Port statement.&lt;br /&gt;
The &lt;i&gt;STD_LOGIC&lt;/i&gt;&amp;nbsp;type is used to represent a digital value. It can assume several values like 0, 1, X (undefined), Z (high impedance) and may others.&lt;br /&gt;
Finally we end the definition of our entity with the&lt;i&gt; "end"&lt;/i&gt; keyword.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: vhdl"&gt;entity AndPort is
    Port ( a : in  STD_LOGIC;
           b : in  STD_LOGIC;
           y : out  STD_LOGIC);
end AndPort;&lt;/pre&gt;
&lt;br /&gt;
Now we describe how our component works using the &lt;i&gt;"architecture"&lt;/i&gt; statement, followed by its name and specifying to which entity it refers with the keyword&lt;i&gt; "of".&lt;/i&gt;&lt;br /&gt;
The keyword &lt;i&gt;begin &lt;/i&gt;and &lt;i&gt;end &lt;/i&gt;will border our architecture statement.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: vhdl"&gt;architecture Behavioral of AndPort is

begin&lt;/pre&gt;
&lt;br /&gt;
The &lt;i&gt;"process" &lt;/i&gt;statement is what actually describes the behavior of our component: it resembles functions from software programming languages.&lt;br /&gt;
We declare it this way: &amp;nbsp;&lt;i&gt;name:process(sensitivity list)&lt;/i&gt; and is delimited by the usual&lt;i&gt; begin&lt;/i&gt; and &lt;i&gt;end &lt;/i&gt;keywords.&lt;br /&gt;
The sensitivity list is a list of signals that are constantly polled: every change in one of it causes the process to execute.&lt;br /&gt;
Inside our process there are our instructions: we assign to the output signal &lt;i&gt;y&lt;/i&gt; the result of the logic AND operation between &lt;i&gt;a &lt;/i&gt;and &lt;i&gt;b&lt;/i&gt;. This is achieved with the &amp;lt;= keyword.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: vhdl"&gt;func:process(a,b)
begin
   y&amp;lt;=(a and b);
end process;

end Behavioral;&lt;/pre&gt;
&lt;br /&gt;
And that's it! Here's the complete code for reference.&lt;br /&gt;
&amp;nbsp;
&lt;span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class="brush: vhdl"&gt;library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity AndPort is
    Port ( a : in  STD_LOGIC;
           b : in  STD_LOGIC;
           y : out  STD_LOGIC);
end AndPort;

architecture Behavioral of AndPort is

begin

func:process(a,b)
begin
   y&amp;lt;=(a and b);
end process;

end Behavioral;
&lt;/pre&gt;
&lt;span style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span style="background-color: white; font-size: 13px; line-height: 19px;"&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
In the video below I show how to create a new project in ISE Webpack and simulate it with ISim.&lt;br /&gt;
Watch it in HD and fullscreen.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://i.ytimg.com/vi/rMKXHDL982U/0.jpg" height="266" width="320"&gt;&lt;param name="movie" value="http://www.youtube.com/v/rMKXHDL982U?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" /&gt;





&lt;param name="bgcolor" value="#FFFFFF" /&gt;





&lt;embed width="320" height="266"  src="http://www.youtube.com/v/rMKXHDL982U?version=3&amp;f=user_uploads&amp;c=google-webdrive-0&amp;app=youtube_gdata" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
I hope this tutorial is clear as we'll deal with more complex topics; if not, don't hesitate to ask!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-9029627553924387801?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=6LL7bLvWang:zo-wyci4mBg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=6LL7bLvWang:zo-wyci4mBg:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=6LL7bLvWang:zo-wyci4mBg:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=6LL7bLvWang:zo-wyci4mBg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=6LL7bLvWang:zo-wyci4mBg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=6LL7bLvWang:zo-wyci4mBg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=6LL7bLvWang:zo-wyci4mBg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=6LL7bLvWang:zo-wyci4mBg:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=6LL7bLvWang:zo-wyci4mBg:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/6LL7bLvWang" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/6LL7bLvWang/learning-vhdl-basics.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2012/01/learning-vhdl-basics.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-3997023358309994948</guid><pubDate>Mon, 16 Jan 2012 20:43:00 +0000</pubDate><atom:updated>2012-01-16T21:50:52.988+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">fpga</category><category domain="http://www.blogger.com/atom/ns#">syntax highlighter</category><category domain="http://www.blogger.com/atom/ns#">vhdl</category><category domain="http://www.blogger.com/atom/ns#">project</category><title>Syntax Highlighter 3 VHDL Brush</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/v3skyIOWDzISwZEzV6UmCwfoQhY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v3skyIOWDzISwZEzV6UmCwfoQhY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/v3skyIOWDzISwZEzV6UmCwfoQhY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/v3skyIOWDzISwZEzV6UmCwfoQhY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;
I've created a simple VHDL for Alex Gorbatchev's &lt;a href="http://alexgorbatchev.com/SyntaxHighlighter/" target="_blank"&gt;Syntax Highlighter 3&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
You can download it &lt;a href="http://dl.dropbox.com/u/6153509/sito/shBrushVhdl.js" target="_blank"&gt;&lt;b&gt;here&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-3997023358309994948?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=wNyQtklGz6M:i4IJYVaXQsQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=wNyQtklGz6M:i4IJYVaXQsQ:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=wNyQtklGz6M:i4IJYVaXQsQ:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=wNyQtklGz6M:i4IJYVaXQsQ:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=wNyQtklGz6M:i4IJYVaXQsQ:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=wNyQtklGz6M:i4IJYVaXQsQ:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=wNyQtklGz6M:i4IJYVaXQsQ:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=wNyQtklGz6M:i4IJYVaXQsQ:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=wNyQtklGz6M:i4IJYVaXQsQ:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/wNyQtklGz6M" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/wNyQtklGz6M/syntax-highlighter-3-vhdl-brush.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2012/01/syntax-highlighter-3-vhdl-brush.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-45822094748704324</guid><pubDate>Sun, 15 Jan 2012 17:50:00 +0000</pubDate><atom:updated>2012-01-16T21:44:14.642+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msp430</category><category domain="http://www.blogger.com/atom/ns#">launchpad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>MSP430 LaunchPad Tutorial - Bonus- UART Transmission</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/QTklD00YIxT_eMztWuSjhu6eAwc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QTklD00YIxT_eMztWuSjhu6eAwc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/QTklD00YIxT_eMztWuSjhu6eAwc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/QTklD00YIxT_eMztWuSjhu6eAwc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Here's a little bonus, as someone requested: I'll just give the code with some basic explanations, so you don't have to deeply understand it but just insert the snippet into your project.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" width="273" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
It comes from TI's&amp;nbsp;MSP430F20xx esamples and it has been readjusted to be used with the Launchpad.&lt;br /&gt;
This snippet is particularly useful if you need to send data from sensors to a serial bluetooth module.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;#include  "msp430g2231.h"

#define     TXD                   BIT1         // TXD on P1.1

//   Conditions for 9600/4=2400 Baud SW UART, SMCLK = 1MHz
#define     Bitime_5              20       // ~ 0.5 bit length + small adjustment
#define     Bitime                52

unsigned char BitCnt;      //Bit Counter
unsigned int  TXByte;      //Data to send

void ConfigureTimerUart(void);
void Transmit(void);

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  BCSCTL1 = CALBC1_1MHZ;                    // Set clock range
  DCOCTL = CALDCO_1MHZ;
  P1SEL |= TXD;                             // Select I/O pins for UART
  P1DIR |= TXD;
  __enable_interrupt();                     

  while(1)
  {
      ConfigureTimerUart();
      TXByte = 0x4B;           //K
      Transmit();
  }
}

void ConfigureTimerUart(void)
{
    CCTL0 = OUT;                               // TXD Idle as Mark
    TACTL = TASSEL_2 + MC_2 + ID_3;            // SMCLK/8, continuous mode
}

// Function Transmits Character from TXByte
void Transmit()
{
  BitCnt = 0xA;                             // Load Bit counter, 8data + ST/SP
  while (CCR0 != TAR)                       // Prevent async capture
    CCR0 = TAR;                             // Current state of TA counter
  CCR0 += Bitime;                          // Some time till first bit
  TXByte |= 0x100;                          // Add mark stop bit to TXByte
  TXByte = TXByte &amp;lt;&amp;lt; 1;               // Add space start bit
  CCTL0 =  CCIS0 + OUTMOD0 + CCIE;          // TXD = mark = idle
  while ( CCTL0 &amp;amp; CCIE );               // Wait for TX completion
}

// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
    CCR0 += Bitime;                           // Add Offset to CCR0
    if (CCTL0 &amp;amp; CCIS0)                    // TX on CCI0B?
    {
      if ( BitCnt == 0)
        CCTL0 &amp;amp;= ~ CCIE;                  // All bits TXed, disable interrupt
      else
      {
        CCTL0 |=  OUTMOD2;                    // TX Space
        if (TXByte &amp;amp; 0x01)
        CCTL0 &amp;amp;= ~ OUTMOD2;               // TX Mark
        TXByte = TXByte &amp;gt;&amp;gt; 1;
        BitCnt --;
      }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
The program transmits the data stored in the TXByte variable on the serial line at 2400 baud.&lt;br /&gt;
It's pretty well commented, you shouldn't finda so much trouble understanding it.&lt;br /&gt;
&lt;br /&gt;
Instead of placing the transmission function in the main loop, you could update TXByte and transmit it in a port interrupt for example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-45822094748704324?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=eGp54YyIoSU:aNrWn542vys:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=eGp54YyIoSU:aNrWn542vys:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=eGp54YyIoSU:aNrWn542vys:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=eGp54YyIoSU:aNrWn542vys:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=eGp54YyIoSU:aNrWn542vys:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=eGp54YyIoSU:aNrWn542vys:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=eGp54YyIoSU:aNrWn542vys:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=eGp54YyIoSU:aNrWn542vys:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=eGp54YyIoSU:aNrWn542vys:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/eGp54YyIoSU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/eGp54YyIoSU/msp430-launchpad-tutorial-bonus-uart.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>2</thr:total><feedburner:origLink>http://www.egarante.net/2012/01/msp430-launchpad-tutorial-bonus-uart.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-7614326179457854672</guid><pubDate>Sun, 29 May 2011 22:21:00 +0000</pubDate><atom:updated>2012-01-23T21:50:01.426+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msp430</category><category domain="http://www.blogger.com/atom/ns#">launchpad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>MSP430 LaunchPad Tutorial - Part 3 - ADC</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/L5pYPUw3g7DBh96Wo1ky704Eodo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L5pYPUw3g7DBh96Wo1ky704Eodo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/L5pYPUw3g7DBh96Wo1ky704Eodo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/L5pYPUw3g7DBh96Wo1ky704Eodo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Finally, here's the last part of this little tutorial series about LaunchPad.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
I'll explain the basics of Analog to Digital Conversion on the MSP430G2231.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" width="273" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
EDIT 01-10-12: Multi-channel conversions added!&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
EDIT 01-23-12:Added "Watch variable" instructions.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;a name='more'&gt;&lt;/a&gt;Basically we'll &amp;nbsp;write a program that will read an ADC channel and will toggle some leds based on the result of the conversion.&lt;br /&gt;
&lt;br /&gt;
We start as usual with the inclusion of the header file for the MSP430G2231, the leds stuff and with the definition of a variable that will store the result of the conversion. We also declare a function that will initialise the ADC module.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;#include  "msp430g2231.h"

#define     LED0                  BIT0
#define     LED1                  BIT6

unsigned int value=0;
&lt;/pre&gt;
&lt;br /&gt;
With this function we setup the ADC module.&lt;br /&gt;
With the ADC10CTL1 register we select the input channl for the ADC and the ADC clock division (from the SBMCLK).&lt;br /&gt;
Then we select the internal voltage reference for the ADC module (Vcc) with SREF_0, turn it on (ADC10ON) and enable the ADC10 interrupt (ADC10IE).&lt;br /&gt;
Finally we connect P1.5 to the ADC module by setting the ADC10AE0 register accordingly.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;void ConfigureAdc(void)
{
  /* Configure ADC  Channel */
  ADC10CTL1 = INCH_5 + ADC10DIV_3 ;         // Channel 5, ADC10CLK/4
  ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE;  //Vcc &amp;amp; Vss as reference
  ADC10AE0 |= BIT5;                         //P1.5 ADC option    
}
&lt;/pre&gt;
&lt;br /&gt;
In the main() &amp;nbsp;we stop as usual the Watchdog timer, set up the clocks and the leds.&lt;br /&gt;
Then we select the input pin for the ADC module by setting the P1SEL register. After that, we initialise the ADC with ConfigureAdc() and enable the interrupts, otherwise we won't know when a conversion has been made.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT  
  BCSCTL1 = CALBC1_1MHZ;                    // Set range
  DCOCTL = CALDCO_1MHZ;
  BCSCTL2 &amp;amp;= ~(DIVS_3);                  // SMCLK = DCO = 1MHz  
  P1DIR |= LED0 + LED1;   
  P1SEL |= BIT5;                             //ADC Input pin P1.5          
  P1OUT &amp;amp;= ~(LED0 + LED1);  
  
  ConfigureAdc();    
  __enable_interrupt();                     // Enable interrupts.
&lt;/pre&gt;
&lt;br /&gt;
After the init stuff, we wait some cycles to let the ADC voltage reference settle to a stable level and then we start the conversion by setting the ADC10CTL0 register. &lt;br /&gt;
Then we enter a low-power mode to save juice: we'll have the result of the conversion directly in our "value" variable from the ADC10MEM register thanks to the ADC10 interrupt.  &lt;br /&gt;
At last we simply toggle the leds on the LaunchPad according to the number stored into "value"   (don't forget that we have a 10-bit ADC module, so the maximum value will be 1023). &lt;br /&gt;
You could do some further calculations, maybe averaging the results to get a more precise reading.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;while(1)
  {    
    __delay_cycles(1000);                   // Wait for ADC Ref to settle 
    ADC10CTL0 |= ENC + ADC10SC;             // Sampling and conversion start
    __bis_SR_register(CPUOFF + GIE);        // LPM0 with interrupts enabled    
    value = ADC10MEM;
    if (value&amp;gt;511)
    {
       P1OUT &amp;amp;= ~(LED0 + LED1);
       P1OUT |= LED0;
    }
    else
    {
       P1OUT &amp;amp;= ~(LED0 + LED1);
       P1OUT |= LED1;}
    }  
}
&lt;/pre&gt;
&lt;br /&gt;
This is the ADC10 interrupt service routine, as we've seen for the TimerA module.&lt;br /&gt;
We simply exit the low-power mode to let the main program make some computations with the result from the ADC.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
  __bic_SR_register_on_exit(CPUOFF);        // Return to active mode
}
&lt;/pre&gt;
&lt;br /&gt;
And that's it! Pretty simple huh? &lt;br /&gt;
This concludes our tutorial series for the LaunchPad, this is all you need to get started with MSP430 MCUs.&lt;br /&gt;
I hope you liked this series, for any questions or suggestions don't hesitate to contact me!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Addendum:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
As someone requested, here's how you do &lt;b&gt;multiple conversions&lt;/b&gt;!&lt;br /&gt;
&lt;br /&gt;
First of all, we define an array that will store the conversion results from each channel&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;#define     ADC_CHANNELS     5  //We will sample 5 channels
unsigned int samples[ADC_CHANNELS];&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
In the main loop, before the start of conversion, we add&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt; &amp;nbsp;ADC10CTL0 &amp;amp;= ~ENC;
  while (ADC10CTL1 &amp;amp; BUSY);
  ADC10SA = (unsigned int)samples; &lt;/pre&gt;
&lt;br /&gt;
With this line we specify that the conversion results should be automatically stored in the previously created array: in such way, there's no need to access the ADC10MEM register anymore. The data will be immediately ready for calculations.&lt;br /&gt;
&lt;br /&gt;
The ConfigureAdc function becomes&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;void ConfigureAdc(void)
{
  /* Configure ADC  Channel */
  ADC10CTL1 = INCH_4 + ADC10DIV_0 + CONSEQ_3 + SHS_0;   //Multi-channel repeated conversion starting from channel 5 
  ADC10CTL0 = SREF_0 + ADC10SHT_2 + MSC + ADC10ON + ADC10IE; 
  ADC10AE0 = BIT4 + BIT3 + BIT2 + BIT1 + BIT0; 
  ADC10DTC1 = ADC_CHANNELS;    //ADC_CHANNELS defined to 5   
}&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
CONSEQ_3 enables multi-channel repeated conversion mode.&lt;br /&gt;
With INCH_4 we select the starting channel (in this case we start from channel 5 the sample channel 4 and so on all the way down to channel 0). We enable ADC on those pins with the ADC10AE0 register.&lt;br /&gt;
MSC enables multi-channel conversions.&lt;br /&gt;
ADC10DTC1 defines how many blocks of data (one for each channel conversion) we transfer into the array &amp;nbsp;adc_channels that we previously created.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style="font-size: large;"&gt;Addendum 2:&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
Here's an image that will explain how to watch variables with CCS while debugging.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-QGsNkHAjzZw/Tx3HzcWERsI/AAAAAAAAAtU/QkAqfu8BUFo/s1600/ccs.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="290" src="http://1.bp.blogspot.com/-QGsNkHAjzZw/Tx3HzcWERsI/AAAAAAAAAtU/QkAqfu8BUFo/s640/ccs.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I hope that your concerns are resolved, otherwise don't hesitate to ask!&lt;br /&gt;
&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-7614326179457854672?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=U2ZGSnbrgSc:OSkQ3jp0scA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=U2ZGSnbrgSc:OSkQ3jp0scA:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=U2ZGSnbrgSc:OSkQ3jp0scA:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=U2ZGSnbrgSc:OSkQ3jp0scA:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=U2ZGSnbrgSc:OSkQ3jp0scA:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=U2ZGSnbrgSc:OSkQ3jp0scA:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=U2ZGSnbrgSc:OSkQ3jp0scA:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=U2ZGSnbrgSc:OSkQ3jp0scA:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=U2ZGSnbrgSc:OSkQ3jp0scA:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/U2ZGSnbrgSc" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/U2ZGSnbrgSc/msp430-launchpad-tutorial-part-3-adc.html</link><author>noreply@blogger.com (Enrico Garante)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-QGsNkHAjzZw/Tx3HzcWERsI/AAAAAAAAAtU/QkAqfu8BUFo/s72-c/ccs.png" height="72" width="72" /><thr:total>26</thr:total><feedburner:origLink>http://www.egarante.net/2011/05/msp430-launchpad-tutorial-part-3-adc.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-8521253650088313479</guid><pubDate>Thu, 10 Feb 2011 15:22:00 +0000</pubDate><atom:updated>2011-11-27T13:44:47.193+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">morse</category><category domain="http://www.blogger.com/atom/ns#">radio</category><category domain="http://www.blogger.com/atom/ns#">launchpad</category><category domain="http://www.blogger.com/atom/ns#">project</category><title>Launchpad Serial Morse TX</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2NcYD9JA3i0i8U-o65FGhs-Fa28/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2NcYD9JA3i0i8U-o65FGhs-Fa28/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2NcYD9JA3i0i8U-o65FGhs-Fa28/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2NcYD9JA3i0i8U-o65FGhs-Fa28/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;Inspired by&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.swharden.com/blog/2010-07-14-high-altitude-balloon-transmitter/" style="background-color: white; cursor: pointer; font-size: 14px; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;this&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;, I decided to build a morse transmitter and add some cool features to it.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white;"&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-size: 14px; line-height: 18px;"&gt;This project shows&amp;nbsp;how to build a little morse transmitter using an MSP430G2231 MCU.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;The device can transmit in two modes:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp;serial, &amp;nbsp;receiving the characters from a COM port &amp;nbsp;and translating them into morse code;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&amp;nbsp; &amp;nbsp;manual, using the key switch.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-size: 14px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://www.instructables.com/image/FEOU438GJQEDKY3/LaunchPad-Serial-Morse-Transmitter.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" height="240" src="http://www.instructables.com/image/FEOU438GJQEDKY3/LaunchPad-Serial-Morse-Transmitter.jpg" width="320" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;&lt;span class="Apple-style-span" style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;Launchpad Morse TX&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;In serial mode, one character at a time is read from the COM port and transmitted as morse at 15 WPM.&amp;nbsp;To better understand how morse code works, read&lt;/span&gt;&lt;u&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/u&gt;&lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Morse_code#Representation.2C_timing_and_speeds" style="background-color: white; cursor: pointer; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;this&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;&amp;nbsp;.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;Morse keying is achieved toggling an output pin connected to the oscillator power pin, thus getting a pure CW mode.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;The device is powered with 2xAA batteries, and the power consumption is kept to a minimum thanks to the Low Power Mode when not transmitting. You may add a second 4xAA supply for the octal buffer in order to increase RF power.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;HARDWARE&lt;/b&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;Here's what you need to build this project:&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="color: #333333;"&gt;&lt;span class="Apple-style-span" style="font-size: 14px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 1x MSP430G2231 Texas Instruments MCU&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 1x 74HC240 Octal buffer&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 1x Oscillator (operating frequency should be in the&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.arrl.org/files/file/Hambands_color.pdf" style="background-color: white; cursor: pointer; font-size: 14px; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;10/12m CW band&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&amp;nbsp;(24/28 MHz))&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 2x 220 ohm resistors&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 2x 1 kohm resistors&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 2x LED (different colors are better)&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 2 push-buttons (included in the Launchpad, you may want to use a better switch for morse keying)&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 2 AA batteries (you may want to use a separate 6V (4AA) supply for 74HC240)&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;- 1m electrical wire (9 AWG)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://www.instructables.com/files/orig/FW8/VYZ4/GJQEG7NY/FW8VYZ4GJQEG7NY.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" height="235" src="http://www.instructables.com/files/orig/FW8/VYZ4/GJQEG7NY/FW8VYZ4GJQEG7NY.png" width="400" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;As you can see from the above schematic, the MCU is used to toggle power to the oscilator, in order to make the ON-OFF modulation needed in morse coding.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;The oscillator's output is then fed to the octal buffer; the amplified signal is the transmitted via the long wire antenna.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;LED1 will indicate the operation mode (Serial or Manual) , LED2 will indicate whether the device is transmitting or not.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;With a first pressure of KEY switch, the device will enter manual mode: further presses will transmit morse code, as a normal morse key.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;To get back to serial mode, just press the RST button.&amp;nbsp;&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;You may build this very easily on a breadboard and use the Lauchpad only to program and host the MCU.&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;As you can see from the photos, I've built a sort of shield for the Lauchpad with male headers, but a future build will surely be on a PCB.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;SOFTWARE&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;The program cycles indefinitely until a character is received on the UART, then encodes it into morse, executes the combinations of dots and dashes on the output pin and finally echoes back the character.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&lt;a href="http://www.instructables.com/files/orig/FTP/4E4M/GJQEG7PQ/FTP4E4MGJQEG7PQ.c"&gt;The code &lt;/a&gt;is pretty well commented, so you shouldn't find much problems understanding it.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;The hard part came when I needed to build a lookup table for the morse code, as there's no known algorithm capable of encoding a character directly into morse. I had to use some defines and combinations of dots and dashes in order to fit the table in the 512 bytes of RAM of the G2231.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;Part of this code is based on NJC's "Half Duplex SW UART on Launchpad"&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.msp430launchpad.com/2010/08/half-duplex-software-uart-on-launchpad.html" style="background-color: white; color: #ff5200; cursor: pointer; font-size: 14px; line-height: 18px; text-decoration: none;"&gt;&amp;nbsp;tutorial&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&amp;nbsp;, read it to better understand how serial communications works on the MSP430.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://2.gvt0.com/vi/nori-RjHEEo/0.jpg" height="266" width="320"&gt;&lt;param name="movie" value="http://www.youtube.com/v/nori-RjHEEo&amp;fs=1&amp;source=uds" /&gt;






&lt;param name="bgcolor" value="#FFFFFF" /&gt;






&lt;embed width="320" height="266"  src="http://www.youtube.com/v/nori-RjHEEo&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;The MSP430 communicates with the Putty terminal via USB thanks to the serial converter built into the Launchpad.&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;As you can see I type characters on the serial terminal and they get transmitted as morse code&amp;nbsp;&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;(I know I'm out of band, but I only had a 24 Mhz oscillator lying around).&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;There's a little delay between typing and the sound because I'm using&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.globaltuners.com/receiver/48/" style="background-color: white; color: #ff5200; cursor: pointer; font-size: 14px; line-height: 18px; text-decoration: none;"&gt;Globaltuners&amp;nbsp;&lt;/a&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;as I can't still afford a real radio receiver :) .&lt;/span&gt;&lt;br style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;" /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;I'm at about 2km from the location of the receiver in the video.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #666666;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://www.instructables.com/image/FDAWBQ3GJQEG7PG/Conclusions.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;img border="0" height="312" src="http://www.instructables.com/image/FDAWBQ3GJQEG7PG/Conclusions.jpg" width="320" /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;There is much to improve in this project.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px; text-align: -webkit-auto;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="text-align: left;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px; text-align: -webkit-auto;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;In a future build i will make a little PCB to fit it in a nice box.&amp;nbsp;Surely I'll change the oscillator with one with a legal frequency.&amp;nbsp;I'll also try to improve the antenna and add an output filter to get a perfect tone.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;On the software side, I'll try to add a buffer for the &amp;nbsp;serial communication and improve the bandwidth. Another thing to change is the delay-driven toggling: hopefully with better MSP430 Value Line devices incoming I'll try to add timer interrupts for this.&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;"&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-size: 14px; line-height: 18px;"&gt;I hope you enjoy building and testing this project as much as I've done.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;Good luck and 73s!&lt;/span&gt;&lt;/div&gt;
&lt;div style="text-align: left;"&gt;
&lt;span class="Apple-style-span" style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class="Apple-style-span" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px;"&gt;UPDATE: check out the post on &lt;a href="http://hackaday.com/2011/02/11/launchpad-serial-morse-code-transmitter/"&gt;Hackaday&lt;/a&gt;, &lt;a href="http://www.43oh.com/2011/02/launchpad-serial-morse-code-transmitter/"&gt;43oh&lt;/a&gt;&amp;nbsp;and &lt;a href="http://dangerousprototypes.com/2011/02/11/ti-launchpad-as-morse-keyer/"&gt;Dangerous Prototypes&lt;/a&gt;!&lt;/span&gt;&lt;br /&gt;
&lt;span class="Apple-style-span" style="color: #333333; font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-8521253650088313479?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=E5r6ibSOjQM:RHeHjkl-bLk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=E5r6ibSOjQM:RHeHjkl-bLk:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=E5r6ibSOjQM:RHeHjkl-bLk:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=E5r6ibSOjQM:RHeHjkl-bLk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=E5r6ibSOjQM:RHeHjkl-bLk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=E5r6ibSOjQM:RHeHjkl-bLk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=E5r6ibSOjQM:RHeHjkl-bLk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=E5r6ibSOjQM:RHeHjkl-bLk:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=E5r6ibSOjQM:RHeHjkl-bLk:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/E5r6ibSOjQM" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/E5r6ibSOjQM/launchpad-serial-morse-tx.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2011/02/launchpad-serial-morse-tx.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-6353196433443557043</guid><pubDate>Sat, 06 Nov 2010 14:50:00 +0000</pubDate><atom:updated>2012-01-05T10:33:10.158+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">electronics</category><category domain="http://www.blogger.com/atom/ns#">project</category><title>1-Watt FM Transmitter</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/1w1LinLAzCPm7ndX2KMUJAv9wfA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1w1LinLAzCPm7ndX2KMUJAv9wfA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/1w1LinLAzCPm7ndX2KMUJAv9wfA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/1w1LinLAzCPm7ndX2KMUJAv9wfA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;This is a simple, portable transmitter operating in the 88-108 MHz FM band.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qCRaC01_njU/TNVrLeCS-0I/AAAAAAAAAdg/yNJgCRZXu0g/s1600/image001.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://4.bp.blogspot.com/_qCRaC01_njU/TNVrLeCS-0I/AAAAAAAAAdg/yNJgCRZXu0g/s320/image001.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;1 Watt FM Transmitter&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You may use it to run your own private neighbourhood radio, just replacing the microphone capsule with a male audio jack connected to your pc or MP3 player. You may also use this as a spy transmitter, but be reasonable in that case! :D&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
It's rated for 1 Watt @ Vcc=18V, so you can listen to it even from a few kilometers, with a good antenna and not too much obstacles in the way. With a 9-12V Vcc it should generate 200-250 mW of RF power anyway.
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qCRaC01_njU/TNVjqU-FQQI/AAAAAAAAAdc/FjsQogl7nAw/s1600/fmradio.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="159" src="http://4.bp.blogspot.com/_qCRaC01_njU/TNVjqU-FQQI/AAAAAAAAAdc/FjsQogl7nAw/s320/fmradio.png" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;FM-TX Schematic&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
Above you can see the schematic.&lt;br /&gt;
&lt;br /&gt;
Here's how it works: the sound captured by the electret microphone is converted into a electrical signal thanks to the voltage drop on the R8 resistor. The mic is powered by the zener diode that drops Vcc to 5.1V, filtered by C8.&lt;br /&gt;
&lt;br /&gt;
This signal is fed to the R7 trimmer (via the DC-decoupling capacitor C2) that controls volume and avoids overmodulation.&lt;br /&gt;
&lt;br /&gt;
Then the signal is amplified about 30 times by the T1 common-emitter amplifier with feedback. This is needed beacuse the transmitter will work in large environments and it has to capture weak sounds and voices. The signal will be inverted by the amplifier, but this doesn't affect the transmission at all.&lt;br /&gt;
&lt;br /&gt;
The amplified signal is the fed to the T2 Hartley oscillator : C9 (feedback), C3 (compensator, selects the transmission frequency) and L1 determine the working frequency.&lt;br /&gt;
The frequency modulation is achieved by varying the T2 bias: the signal from T1 is added to the bias voltage&amp;nbsp;from the R3/R5 divider. This change of the T2 base potential varies the functioning of its junctions and, with them, alters the value of the parasitic capacitance (especially the collector-junction one tha is in parallel with C3) and we have a shift in the working frequency of the RF oscillator.&lt;br /&gt;
&lt;br /&gt;
Finally the signal is directly irradiated by the L1 coil.&lt;br /&gt;
&lt;br /&gt;
Please note that the L1 coil is made wrapping 4 windings of a 1mm copper wire on a 7mm long support, that will be removed before soldering the coil.&lt;br /&gt;
&lt;br /&gt;
If you want, you may add a 70cm long wire as antenna near the first coil of L1 from the T2-collector side, or even better a ground-plane FM antenna with a shielded coaxial cable.&lt;br /&gt;
&lt;br /&gt;
I recommend to build the circuit on a perf-board or better to etch its own board.&lt;br /&gt;
Be sure to add an heatsink to the 2N2219 transistor (T2), especially if you use an antenna.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-6353196433443557043?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=u_RcB9JT0LA:R-hF4OriLEU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=u_RcB9JT0LA:R-hF4OriLEU:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=u_RcB9JT0LA:R-hF4OriLEU:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=u_RcB9JT0LA:R-hF4OriLEU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=u_RcB9JT0LA:R-hF4OriLEU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=u_RcB9JT0LA:R-hF4OriLEU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=u_RcB9JT0LA:R-hF4OriLEU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=u_RcB9JT0LA:R-hF4OriLEU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=u_RcB9JT0LA:R-hF4OriLEU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/u_RcB9JT0LA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/u_RcB9JT0LA/1-watt-fm-transmitter.html</link><author>noreply@blogger.com (Enrico Garante)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_qCRaC01_njU/TNVrLeCS-0I/AAAAAAAAAdg/yNJgCRZXu0g/s72-c/image001.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2010/11/1-watt-fm-transmitter.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-7832042354121535133</guid><pubDate>Tue, 12 Oct 2010 12:51:00 +0000</pubDate><atom:updated>2012-01-20T21:13:08.000+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msp430</category><category domain="http://www.blogger.com/atom/ns#">launchpad</category><category domain="http://www.blogger.com/atom/ns#">project</category><title>MSPoV430 - POV with Launchpad</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/ehRPgxm6n7aXOm2RQc-re8GflX4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ehRPgxm6n7aXOm2RQc-re8GflX4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/ehRPgxm6n7aXOm2RQc-re8GflX4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/ehRPgxm6n7aXOm2RQc-re8GflX4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;I've used the little MSP430G2231 for my first "Persistence of Vision" project.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;img border="0" height="240" src="http://3.bp.blogspot.com/_qCRaC01_njU/TK9YovHlsTI/AAAAAAAAAdU/8TBQLX0PkVQ/s320/DSCN0091.JPG" style="margin-left: auto; margin-right: auto;" width="320" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;PoV with MSP430&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/_qCRaC01_njU/TK9YovHlsTI/AAAAAAAAAdU/8TBQLX0PkVQ/s1600/DSCN0091.JPG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
As you can see, there's only the MSP430G2231 connected directly to the leds (there's no need for series resistor, the mcu supplies the right current for each led). The other connections are supply power (2 AA batteries) and RST pin to Vcc.&lt;br /&gt;
&lt;br /&gt;
Here's the schematic&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-ye6p6hPWAuc/TwsB5T64XdI/AAAAAAAAAq8/rG7W5Gu2CLk/s1600/Immagine.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="348" src="http://2.bp.blogspot.com/-ye6p6hPWAuc/TwsB5T64XdI/AAAAAAAAAq8/rG7W5Gu2CLk/s400/Immagine.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
I plan to improve it by modifying the shape of the board to a rod, add "string-recognition" and add a button to change the displayed message.&lt;br /&gt;
&lt;br /&gt;
Here's it in action.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;img border="0" height="240" src="http://1.bp.blogspot.com/_qCRaC01_njU/TK9bZ4_nDsI/AAAAAAAAAdY/3EYMQmYCz1M/s320/pov.png" style="margin-left: auto; margin-right: auto;" width="320" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Hello World!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/_qCRaC01_njU/TK9bZ4_nDsI/AAAAAAAAAdY/3EYMQmYCz1M/s1600/pov.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This is the complete code. In the "pov" array we store each column of the message to display. Each value is then sent to the output port connected to the leds. This happens at every interrupt from the timer (400 Hz frequency).&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;#include "msp430g2231.h"

unsigned char i = 0;
unsigned char disp = 0;
unsigned char pov[35]= {
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFF,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x18,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x18,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFF,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFF,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x91,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x91,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x91,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFF,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFF,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x80,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFF,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x81,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x81,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0xFF,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x00&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; };&amp;nbsp;

void delay_ms(unsigned int ms )&amp;nbsp;&amp;nbsp;// MS delay function
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned int i;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i&amp;lt;= ms; i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; __delay_cycles(500);
}

void main(void)
{
&amp;nbsp; WDTCTL = WDTPW + WDTHOLD;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Stop WDT&amp;nbsp; 
&amp;nbsp; CCTL0 = CCIE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // CCR0 interrupt enabled
&amp;nbsp; CCR0 = 313;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // 400 Hz-&amp;gt;313
&amp;nbsp; TACTL = TASSEL_2 + MC_1 + ID_3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // SMCLK/8, upmode
&amp;nbsp; P1DIR |= 0xFF; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // All P1 pins output
&amp;nbsp; P1OUT &amp;amp;= 0x00;
&amp;nbsp; _BIS_SR(CPUOFF + GIE);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enter LPM0 w/ interrupt
&amp;nbsp; while(1)
&amp;nbsp; {}
}

// Timer A0 interrupt service routine
// Display a row from the array
#pragma vector=TIMERA0_VECTOR  
__interrupt void Timer_A (void)
{
&amp;nbsp; disp^=1;
&amp;nbsp; if(disp!=0)
&amp;nbsp; {&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; if(i==35) //cycle the array
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; i=0;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; P1OUT|=pov[i];  //Turn on the selected leds
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; i++;
&amp;nbsp; }
&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; P1OUT&amp;amp;=0x00;
} 
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-7832042354121535133?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=UYeyrGDGMao:s_dfFjC1QbU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=UYeyrGDGMao:s_dfFjC1QbU:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=UYeyrGDGMao:s_dfFjC1QbU:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=UYeyrGDGMao:s_dfFjC1QbU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=UYeyrGDGMao:s_dfFjC1QbU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=UYeyrGDGMao:s_dfFjC1QbU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=UYeyrGDGMao:s_dfFjC1QbU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=UYeyrGDGMao:s_dfFjC1QbU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=UYeyrGDGMao:s_dfFjC1QbU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/UYeyrGDGMao" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/UYeyrGDGMao/mspov430-pov-with-launchpad.html</link><author>noreply@blogger.com (Enrico Garante)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_qCRaC01_njU/TK9YovHlsTI/AAAAAAAAAdU/8TBQLX0PkVQ/s72-c/DSCN0091.JPG" height="72" width="72" /><thr:total>4</thr:total><feedburner:origLink>http://www.egarante.net/2010/10/mspov430-pov-with-launchpad.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-1929574749095110949</guid><pubDate>Tue, 28 Sep 2010 17:49:00 +0000</pubDate><atom:updated>2011-09-14T11:30:32.982+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msp430</category><category domain="http://www.blogger.com/atom/ns#">launchpad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>MSP430 Launchpad Tutorial - Part 2 - Interrupts and timers</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RZbdhrEmEFF8M3AMkhrKeA2JLAc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RZbdhrEmEFF8M3AMkhrKeA2JLAc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RZbdhrEmEFF8M3AMkhrKeA2JLAc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RZbdhrEmEFF8M3AMkhrKeA2JLAc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="font-family: Verdana,sans-serif;"&gt;In this tutorial, you'll learn how to use timers and interrupts with the MSP430 MCUs.&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="320" src="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" width="273" /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
What is an "&lt;a href="http://en.wikipedia.org/wiki/Interrupt"&gt;interrupt&lt;/a&gt;"?&amp;nbsp; It is a signal that informs our MCU that a certain event has happened, causing the interruption of the normal flow of the main program and the execution of an "interrupt routine", that handles the event and takes a specified action.&lt;br /&gt;
&lt;br /&gt;
Interrupts are essential to avoid wasting the processor's valuable time in polling loops, waiting for external events (in fact they are used in Real-Time Operating Systems, &lt;a href="http://en.wikipedia.org/wiki/RTOS"&gt;RTOS&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
In the MSP430 architecture, there are several types of interrupts: timer interrupts, port interrupts, ADC interrupts and so on. Each one of them needs to be enabled and configured to work, and there is a separate "service routine" for every interrupt.&lt;br /&gt;
&lt;br /&gt;
In this tutorial we'll see how to use timer and port interrupts to flash some leds, we'll keep the ADC interrupt for the next tutorial.&lt;br /&gt;
&lt;br /&gt;
So, let's write some code!&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;#include "msp430g2231.h"&amp;nbsp;
void main(void)
{
&amp;nbsp; WDTCTL = WDTPW + WDTHOLD;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Stop WDT&amp;nbsp;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;
You should recognize those lines,we used them in the last tutorial to add the definition file for our MCU, declare the main function and stop the watchdog timer.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;&amp;nbsp; CCTL0 = CCIE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // CCR0 interrupt enabled
&amp;nbsp; TACTL = TASSEL_2 + MC_1 + ID_3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // SMCLK/8, upmode&amp;nbsp;&amp;nbsp;
&amp;nbsp; CCR0 =&amp;nbsp; 10000;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 125 Hz&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/pre&gt;&lt;br /&gt;
Here's some interesting stuff. These lines configure the timer interrupt. We first enable it by setting the CCIE bit in the CCTL0 register.&lt;br /&gt;
Then we set the clock for the timer module in the TimerA control register.&lt;br /&gt;
If you have a look at the msp430g2231.h file, you can see that: &lt;br /&gt;
&lt;ul&gt;&lt;li&gt;TASSEL_2 selects the SMCLK (supplied by an internal DCO which runs at about 1 MHz); &lt;/li&gt;
&lt;li&gt;MC_1 selects the "UP mode", the timer counts up to the number stored in the CCR0 register; &lt;/li&gt;
&lt;li&gt;ID_3 selects an internal 8x divider for the supplied clock (in our case we have SMCLK/8).&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
Finally, we set the CCR0 register. We configured the TimerA module to count up to the number stored in this register before overflowing and triggering the interrupt.&lt;br /&gt;
By setting it at 10000, we get an overflow-frequency of 12,5 Hz. In fact we have (SMCLK/8)/10000 = 12,5 .&lt;br /&gt;
You may obtain several frequencies by changing this number (remember that the MSP430 has a 16-bit timer, so the value stored in the CCR0 register must not be higher than 65535), changing the dividers or adding an if-else block with a counter in the interrupt routine.&lt;br /&gt;
Let's go ahead.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;&amp;nbsp; P1DIR |= BIT0 + BIT6; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // All P1 pins output
&amp;nbsp; P1OUT &amp;amp;= 0x00;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Shut. Down. Everything... :)&lt;/pre&gt;&lt;br /&gt;
These lines should be familiar too, we set the P1.0 and P1.6 pins to output direction and set all the pins to 0 logic level.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;&amp;nbsp; P1IE |= BIT3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // P1.3 interrupt enabled
&amp;nbsp; //P1IES |= BIT3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // P1.3 Hi/lo edge
&amp;nbsp; P1IFG &amp;amp;= ~BIT3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // P1.3 IFG cleared&lt;/pre&gt;&lt;br /&gt;
With these lines of code, we first tell the MCU to listen to the P1.3 pin for logic-state changes (effectively enabling the interrupt on that particular pin), and then clear the interrupt flag for that pin.&lt;br /&gt;
The interrput flag register P1IFG reports when an interrupt is raised, and it should be cleared at the end of the interrupt service routine.&lt;br /&gt;
The commented line in the middle is used to change the edge when the interrupt is raised (Hi-Lo or Lo-Hi, remember that the button on the LaunchPad is connected to GND when pushed). &lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;&amp;nbsp; _BIS_SR(CPUOFF + GIE);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enter LPM0 w/ interrupt&amp;nbsp;&amp;nbsp; while(1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Loop forever, we do&amp;nbsp; everything with interrupts!
&amp;nbsp; {}
}
&lt;/pre&gt;&lt;br /&gt;
With this line, as you remember (do you remember right? :\ ), we shut down the CPU to spare some power while keeping the interrupts enabled. Then we enter a loop to be sure the MCU does nothing else, as we do our dirty job with interrupts.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
&amp;nbsp; P1OUT ^= BIT0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; // Toggle P1.0
}&lt;/pre&gt;This is the TimerA interrupt service routine. Every time the TimerA overflows, the code inserted in this routine (note the special declaration) is executed. As you can see we only toggle the P1.0 pin (red led on LaunchPad), then we return to normal execution.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; P1OUT ^= BIT6;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; // Toggle P1.6&amp;nbsp;&amp;nbsp; 
   P1IFG &amp;amp;=~BIT3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  // P1.3 IFG cleared&amp;nbsp;&amp;nbsp;&amp;nbsp; 
}&amp;nbsp;&lt;/pre&gt;This is the Port1 interrupt service routine. Every time the we push the P1.3 button, the code inserted in this routine (note the special  declaration) is executed. As you can see we, toggle the P1.6 pin  (greenled on LaunchPad), clear the P1.3 interrupt flag (very important) then we return to normal execution.&lt;br /&gt;
&lt;br /&gt;
Compile and program the LaunchPad, you should see the red led blink, and the green led toggle on and off when you press the P1.3 button.&lt;br /&gt;
&lt;br /&gt;
Here's the full code, enjoy!&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: cpp"&gt;#include "msp430g2231.h"&amp;nbsp;&amp;nbsp;
&amp;nbsp;
void main(void)
{
&amp;nbsp; WDTCTL = WDTPW + WDTHOLD;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Stop WDT&amp;nbsp;&amp;nbsp;
&amp;nbsp; CCTL0 = CCIE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // CCR0 interrupt enabled
&amp;nbsp; TACTL = TASSEL_2 + MC_1 + ID_3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // SMCLK/8, upmode
&amp;nbsp; CCR0 =&amp;nbsp; 10000;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // 125 Hz&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp; P1DIR |= BIT0 + BIT6; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // All P1 pins output
&amp;nbsp; P1OUT &amp;amp;= 0x00;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Shut. Down. Everything... :)
&amp;nbsp; P1IE |= BIT3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // P1.3 interrupt enabled
&amp;nbsp; //P1IES |= BIT3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // P1.3 Hi/lo edge
&amp;nbsp; P1IFG &amp;amp;= ~BIT3;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // P1.3 IFG cleared
&amp;nbsp; _BIS_SR(CPUOFF + GIE);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Enter LPM0 w/ interrupt&amp;nbsp;
&amp;nbsp; while(1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Loop forever, we work with interrupts!
&amp;nbsp; {}
}&amp;nbsp;
&amp;nbsp;
// Timer A0 interrupt service routine&amp;nbsp;
#pragma vector=TIMERA0_VECTOR&amp;nbsp;
__interrupt void Timer_A (void)&amp;nbsp;
{ &amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; P1OUT ^= BIT0;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; // Toggle P1.0&amp;nbsp;
}&amp;nbsp;
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp; P1OUT ^= BIT6;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Toggle P1.6
   P1IFG &amp;amp;= ~BIT3;                     // P1.3 IFG cleared&amp;nbsp;
}&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-1929574749095110949?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=dQ97TcbCQjg:Ae6tQrg4wSI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=dQ97TcbCQjg:Ae6tQrg4wSI:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=dQ97TcbCQjg:Ae6tQrg4wSI:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=dQ97TcbCQjg:Ae6tQrg4wSI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=dQ97TcbCQjg:Ae6tQrg4wSI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=dQ97TcbCQjg:Ae6tQrg4wSI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=dQ97TcbCQjg:Ae6tQrg4wSI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=dQ97TcbCQjg:Ae6tQrg4wSI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=dQ97TcbCQjg:Ae6tQrg4wSI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/dQ97TcbCQjg" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/dQ97TcbCQjg/msp430-launchpad-tutorial-part-2.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>22</thr:total><feedburner:origLink>http://www.egarante.net/2010/09/msp430-launchpad-tutorial-part-2.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-6229767212887158102</guid><pubDate>Wed, 22 Sep 2010 19:44:00 +0000</pubDate><atom:updated>2011-11-27T13:43:00.180+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">arduino</category><category domain="http://www.blogger.com/atom/ns#">project</category><title>Homebrew Arduino</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/n4o8MJGX5iAIZoJCcLVFoU4p_PE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/n4o8MJGX5iAIZoJCcLVFoU4p_PE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/n4o8MJGX5iAIZoJCcLVFoU4p_PE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/n4o8MJGX5iAIZoJCcLVFoU4p_PE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
This is my homemade Arduino board, I used it for &lt;a href="http://www.egarante.net/2010/09/arduino-blindwalk.html"&gt;Blindwalk&lt;/a&gt; and I'll surely stick with it for my future projects.&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;img border="0" height="320" src="http://img339.imageshack.us/img339/5685/s1051285.jpg" style="margin-left: auto; margin-right: auto;" width="240" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Homemade Arduino is fun!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://img339.imageshack.us/img339/5685/s1051285.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name='more'&gt;&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
Here's the schematic: as you can see, you need very few extra components are needed (and an &lt;a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9115"&gt;FTDI Basic Breakout&lt;/a&gt; from Sparkfun). &lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;br /&gt;
&lt;img border="0" height="348" src="http://4.bp.blogspot.com/_qCRaC01_njU/TJiV-Mn5cKI/AAAAAAAAAc0/Z7PVOJr8IJo/s640/board.png" width="640" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Schematic&lt;br /&gt;
&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
The chip is an &lt;a href="http://www.atmel.com/dyn/products/product_card.asp?PN=ATmega328P"&gt;ATMega328&lt;/a&gt; with pre-loaded Arduino Bootloader, and of course it is fully compatible with the Arduino IDE.&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;img border="0" height="200" src="http://static.sparkfun.com/images/products/09115-03-L.jpg" style="margin-left: auto; margin-right: auto;" width="200" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Sparkfun FTDI Basic Breakout&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://static.sparkfun.com/images/products/09115-03-L.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-6229767212887158102?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=G5YJU54C8jU:qaeXJjdYUdE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=G5YJU54C8jU:qaeXJjdYUdE:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=G5YJU54C8jU:qaeXJjdYUdE:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=G5YJU54C8jU:qaeXJjdYUdE:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=G5YJU54C8jU:qaeXJjdYUdE:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=G5YJU54C8jU:qaeXJjdYUdE:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=G5YJU54C8jU:qaeXJjdYUdE:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=G5YJU54C8jU:qaeXJjdYUdE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=G5YJU54C8jU:qaeXJjdYUdE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/G5YJU54C8jU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/G5YJU54C8jU/homebrew-arduino.html</link><author>noreply@blogger.com (Enrico Garante)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_qCRaC01_njU/TJiV-Mn5cKI/AAAAAAAAAc0/Z7PVOJr8IJo/s72-c/board.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2010/09/homebrew-arduino.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-2824791194913241140</guid><pubDate>Tue, 21 Sep 2010 08:10:00 +0000</pubDate><atom:updated>2012-01-09T15:51:19.869+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">electronics</category><category domain="http://www.blogger.com/atom/ns#">arduino</category><category domain="http://www.blogger.com/atom/ns#">gp2d12</category><category domain="http://www.blogger.com/atom/ns#">project</category><title>Arduino BlindWalk</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/wFWmqlJko3Etz6mQvQg4EVCoTFY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wFWmqlJko3Etz6mQvQg4EVCoTFY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/wFWmqlJko3Etz6mQvQg4EVCoTFY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/wFWmqlJko3Etz6mQvQg4EVCoTFY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
BlindWalk is a little project I've built to test my &lt;a href="http://www.egarante.net/2010/09/homebrew-arduino.html"&gt;homemade Arduino board&lt;/a&gt;.&lt;/div&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif; margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://img408.imageshack.us/img408/960/s1051283.jpg" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://img408.imageshack.us/img408/960/s1051283.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;BlindWalk&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;a name='more'&gt;&lt;/a&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;
As you can see, it is a basic ATMega328 board, with a 5V regulator an an &lt;a href="http://www.sparkfun.com/commerce/product_info.php?products_id=9115"&gt;FTDI Basic Breakout&lt;/a&gt; to add USB connectivity. You can see a tutorial on how to do it (and spare a lot of money too)&lt;a href="http://itp.nyu.edu/physcomp/Tutorials/ArduinoBreadboard"&gt; here&lt;/a&gt;.&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
But let's talk about BlindWalk. BlindWalk, as the name says, allows you to walk in the dark by the only mean of a beeping sound and a blinking led. The beep becomes more frequent as nearer you get to an obstacle.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;img border="0" height="473" src="http://1.bp.blogspot.com/_qCRaC01_njU/TJSRV007aJI/AAAAAAAAAck/JJY949rVUbE/s640/schematic.png" style="margin-left: auto; margin-right: auto;" width="640" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;BlindWalk Schematic&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
It's not a concentrate of technology, but it does its dirty job. I used a &lt;a href="http://document.sharpsma.com/files/GP2D12J0000F_SS_20060207.pdf"&gt;Sharp GP2D12&lt;/a&gt;&amp;nbsp; IR distance sensor, a piezo speaker and a push switch to detect an impact (in fact the GP2D12 is useless under 10 cm). I've thought to put a super bright led, but the fun to walk in the dark would be drastically reduced&amp;nbsp; :)&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
Below you can see the code.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/_qCRaC01_njU/TJSRV007aJI/AAAAAAAAAck/JJY949rVUbE/s1600/schematic.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre class="brush: cpp"&gt;float distance(int analog)&amp;nbsp;&amp;nbsp;&amp;nbsp; //returns distance in centimeters, we don't use it for now but is useful
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (analog &amp;lt; 3)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return -1; // invalid value
&amp;nbsp;&amp;nbsp;&amp;nbsp; return (6787.0 /((float)analog - 3.0)) - 0.4;
&amp;nbsp;} 

&amp;nbsp;void setup()
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp; pinMode(8 ,&amp;nbsp; INPUT);
&amp;nbsp;&amp;nbsp;&amp;nbsp; pinMode(11, OUTPUT);
&amp;nbsp;&amp;nbsp;&amp;nbsp; pinMode(13, OUTPUT);
&amp;nbsp;}

&amp;nbsp;void loop()
&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (digitalRead(8) == HIGH)&amp;nbsp; //Check the switch for an impact
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; digitalWrite(13,HIGH);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tone(11,466,100);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Continuous tone
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; digitalWrite(13,HIGH); 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; float analog = analogRead(0);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tone(11,466,100);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; digitalWrite(13,LOW);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay(750-analog);&amp;nbsp;&amp;nbsp;&amp;nbsp; //beep according to the distance measured
&amp;nbsp;&amp;nbsp; }
&amp;nbsp;}&amp;nbsp;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
I'll try to fit all of the hardware in a nice plastic box.&lt;br /&gt;
And here's a video of BlindWalk in action.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;object height="344" width="425"&gt;&lt;param name="movie" value="http://www.youtube.com/v/n81mSmqD5JI?hl=it&amp;fs=1"&gt;
&lt;/param&gt;
&lt;param name="allowFullScreen" value="true"&gt;
&lt;/param&gt;
&lt;param name="allowscriptaccess" value="always"&gt;
&lt;/param&gt;
&lt;embed src="http://www.youtube.com/v/n81mSmqD5JI?hl=it&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-2824791194913241140?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=LXIYGsQ2JSo:evXIHNT4Rnw:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=LXIYGsQ2JSo:evXIHNT4Rnw:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=LXIYGsQ2JSo:evXIHNT4Rnw:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=LXIYGsQ2JSo:evXIHNT4Rnw:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=LXIYGsQ2JSo:evXIHNT4Rnw:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=LXIYGsQ2JSo:evXIHNT4Rnw:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=LXIYGsQ2JSo:evXIHNT4Rnw:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=LXIYGsQ2JSo:evXIHNT4Rnw:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=LXIYGsQ2JSo:evXIHNT4Rnw:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/LXIYGsQ2JSo" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/LXIYGsQ2JSo/arduino-blindwalk.html</link><author>noreply@blogger.com (Enrico Garante)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_qCRaC01_njU/TJSRV007aJI/AAAAAAAAAck/JJY949rVUbE/s72-c/schematic.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2010/09/arduino-blindwalk.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-5793571777729585698</guid><pubDate>Sat, 18 Sep 2010 13:17:00 +0000</pubDate><atom:updated>2012-01-14T15:12:49.285+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msp430</category><category domain="http://www.blogger.com/atom/ns#">eagle</category><title>MSP430G2xx Eagle Library</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/SbKYPJUY9xLmeLbgrV4R5XRliFA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SbKYPJUY9xLmeLbgrV4R5XRliFA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/SbKYPJUY9xLmeLbgrV4R5XRliFA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/SbKYPJUY9xLmeLbgrV4R5XRliFA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
Here's an Eagle Library I've made to use MSP430 Value Line devices on our PCBs.&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;
&lt;a href="http://processors.wiki.ti.com/images/thumb/2/28/MSP430_SOIC.jpg/250px-MSP430_SOIC.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://processors.wiki.ti.com/images/thumb/2/28/MSP430_SOIC.jpg/250px-MSP430_SOIC.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
&lt;br /&gt;
&lt;b&gt;Download &lt;a href="http://db.tt/oR2Hx68c" target="_blank"&gt;here&lt;/a&gt;.&lt;/b&gt;&lt;/div&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;
Let me know if you find errors...&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-5793571777729585698?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=CdTBZJE-8gI:LchkcG0bqKU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=CdTBZJE-8gI:LchkcG0bqKU:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=CdTBZJE-8gI:LchkcG0bqKU:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=CdTBZJE-8gI:LchkcG0bqKU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=CdTBZJE-8gI:LchkcG0bqKU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=CdTBZJE-8gI:LchkcG0bqKU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=CdTBZJE-8gI:LchkcG0bqKU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=CdTBZJE-8gI:LchkcG0bqKU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=CdTBZJE-8gI:LchkcG0bqKU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/CdTBZJE-8gI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/CdTBZJE-8gI/msp430g2xx-eagle-library.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>2</thr:total><feedburner:origLink>http://www.egarante.net/2010/09/msp430g2xx-eagle-library.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-1641093669859288182</guid><pubDate>Wed, 15 Sep 2010 15:33:00 +0000</pubDate><atom:updated>2011-07-10T11:49:33.832+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msp430</category><category domain="http://www.blogger.com/atom/ns#">launchpad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>MSP430 Launchpad Tutorial - Part 1 - Basics</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/15V8i0MZWDg81Tsu3aQENn4QZeA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/15V8i0MZWDg81Tsu3aQENn4QZeA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/15V8i0MZWDg81Tsu3aQENn4QZeA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/15V8i0MZWDg81Tsu3aQENn4QZeA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;After a week spent in the bed (I've had a bad flu :\ ) , I'm ready to publish my first MSP430 tutorial! &lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;TI's LaunchPad is a complete MSP430 development environment: all you have to do is download and install &lt;a href="http://software-dl-1.ti.com/dsps/forms/self_cert_export.html?prod_no=setup_CCS_MC_Core.zip&amp;amp;ref_url=http://software-dl-1.ti.com/dsps/dsps_public_sw/sdo_ccstudio/CCSv4/latest/"&gt;CCS IDE&lt;/a&gt; (login required), connect your G2231-ready LaunchPad to your computer with the included mini-usb cable, and you are ready to code!&lt;/div&gt;&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;img border="0" height="320" src="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" style="margin-left: auto; margin-right: auto;" width="273" /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Texas Instrument MSP430 LaunchPad&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://processors.wiki.ti.com/images/thumb/a/ad/LaunchPad_wireframe.PNG/300px-LaunchPad_wireframe.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;So, let's see how to start a new project in Code Composer Studio. This IDE is derived from Eclipse, so if you used it before you shouldn't have much problems.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;We'll program a simple program that will toggle a led when we press the on-board button.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Go to New-&amp;gt;CCS Project&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_qCRaC01_njU/TJDjOMup9hI/AAAAAAAAAb0/754_qaPng28/s1600/ccs2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_qCRaC01_njU/TJDjOMup9hI/AAAAAAAAAb0/754_qaPng28/s320/ccs2.png" /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Give a name and a destination folder to your project, then click "Next". Be sure to select "MSP430" in the next window, then go ahead. Don't care about the "Additional Project Settings" window for now, and click "Next". In the "Project Settings" window, be sure to have everything set like this picture.&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://4.bp.blogspot.com/_qCRaC01_njU/TJDkBpt7_uI/AAAAAAAAAb8/FGf28Aik_ZA/s1600/ccs1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_qCRaC01_njU/TJDkBpt7_uI/AAAAAAAAAb8/FGf28Aik_ZA/s320/ccs1.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;In the "Device Variant" field, select the correct MCU you have installed on your LaunchPad, then click "Finish". &lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Now we have to add a "main.c" file to our project. Right-click on your project name (note that it is in bold and has "Active - Debug" tags, meaning it will be the main project that will be compiled and debugged later on). Select "New-&amp;gt;Source File".&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qCRaC01_njU/TJDlrzkPReI/AAAAAAAAAcE/lYoGTAjPdts/s1600/ccs3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_qCRaC01_njU/TJDlrzkPReI/AAAAAAAAAcE/lYoGTAjPdts/s320/ccs3.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Call it "main.c" then click finish. Now we are ready to add some real code!&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Our first line of code will be this&lt;/div&gt;&lt;pre class="brush: cpp"&gt;#include "msp430g2231.h"  //Contains all definitions for registers and built-in functions&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;With this we include the definitions of registers and built-in functions for the MSP430G2231 e.g. if you used the other chip, the G2211, you had to include"msp430g2211.h" header file.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Next, we have the main routine.&lt;/div&gt;&lt;pre class="brush: cpp"&gt;int main(void)  //Main program
{
 WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
 
 P1DIR |= BIT0; // Set P1.0 to output and P1.3 to input direction
 P1OUT &amp;amp;= ~BIT0; // set P1.0 to Off
 P1IE |= BIT3; // P1.3 interrupt enabled
 P1IFG &amp;amp;= ~BIT3; // P1.3 interrupt flag cleared
 
 __bis_SR_register(GIE); // Enable all interrupts
 
 while(1) //Loop forever, we'll do our job in the interrupt routine...
 {}
}&lt;/pre&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;It's quite a mere "setup" routine, as we don't do nothing that involves the led toggleing.&lt;/div&gt;&lt;pre class="brush: cpp"&gt;WDTCTL = WDTPW + WDTHOLD;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;With this line, we stop the "Watchdog timer":&amp;nbsp; it is typically used to reset the MCU after a  certain amount of time, to prevent deadlocks and infinite loops. In most examples, you will see that the watchdog timer  is stopped during the first line of code, to avoid unwanted resets.&lt;/div&gt;&lt;pre class="brush: cpp"&gt;P1DIR |= BIT0;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;With this instruction, we set the P1.0 pin (which is connected to the red led on the LaunchPad) to the output direction. In the MSP430 architecture, P1DIR is a 8-bit register that controls the i/o direction of the Port 1 pins. If you set a bit to 0, it is configured as an input, otherwise it is an output. The BIT0 constant is simply the 0x01 hex number, so you do this :&lt;/div&gt;&lt;br /&gt;
P1DIR before&amp;nbsp;&amp;nbsp; 00000000+&amp;nbsp; &lt;br /&gt;
BIT0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 00000001=&lt;br /&gt;
P1DIR after&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 00000001&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;This way, all the Port1 pins are set to input direction, except for P1.0 which is our led.&lt;/div&gt;&lt;pre class="c" name="code"&gt;P1OUT &amp;amp;= ~BIT0;&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Whit this,we resetthe P1.0 output . In fact, the P1OUT register controls all the output pins: if you put a bit to 1 (by or-ing the P1OUT register with the right numeric constant BIT0, BIT1...), the relative output pin is set on HIGH logical level, otherwise (by and-ing the P1OUT register with the inverted numeric constant) it is set on a LOW level.&lt;/div&gt;&lt;pre class="brush: cpp"&gt;P1IE |= BIT3; // P1.3 interrupt enabled
P1IFG &amp;amp;= ~BIT3; // P1.3 interrupt flag cleared&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;With these two instruction, we enable the interrupt on the P1.3 input pin (the on-board button).&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;What is an interrupt? Well, this is not the rigth time, but for now I'll you only have to know that this two lines of code allows the chip to know when the button has been pressed, even if he is doing other things (like calculations, delays ecc...). The P1IE register is used to enable interrupts on an input pin (it works like the P1DIR e P1OUT registers), and the P1IFG register is used to know if the desired event (in this case the press of the button) has happened (then the relative bit is set to 1) or not (the bit is set to 0).&lt;/div&gt;&lt;pre class="brush: cpp"&gt;__bis_SR_register(GIE);&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;With this built-in function, we enable all the interrupts by setting the GIE (Global Interrupt Enable) bit in the Status Register of the MSP430G2231. This function is also used to enter Low-Power modes, but this will be covered in a future tutorial.&lt;/div&gt;&lt;pre class="brush: cpp"&gt;while(1) {}&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Finally, we enter an infinite-loop, as we have nothing more to do in the main function.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;In fact, we will actually toggle the led in the "Port 1 interrupt service routine". This routine is called every time the state of a interrupt-enabled P1 pin changes from high to low (the button on the LaunchPad is active-low).&lt;/div&gt;&lt;pre class="brush: cpp"&gt;#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; P1OUT ^= BIT0;&amp;nbsp; // Toggle P1.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; P1IFG &amp;amp;= ~BIT3; // P1.3 interrupt flag cleared
}&lt;/pre&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;The first line of this function (P1OUT ^= BIT0;) toggles the pin state by xor-ing it. Then the Interrupt flag is set back to 0 in order to listen for another interrupt.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Now we are ready to launch the code on CCS.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Be sure to have the LaunchPad connected to your PC, then press the little green-bug button on the IDE to compile, download the code and enter the debug perspective.&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_qCRaC01_njU/TJEF_MJpzqI/AAAAAAAAAcM/uCyYJf77Pus/s1600/ccs4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="33" src="http://1.bp.blogspot.com/_qCRaC01_njU/TJEF_MJpzqI/AAAAAAAAAcM/uCyYJf77Pus/s640/ccs4.png" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Then press the "Play" button to start execution, the "Stop" button to exit debugging and the "Chip" button to reset the board.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href="http://3.bp.blogspot.com/_qCRaC01_njU/TJEHB6YcRKI/AAAAAAAAAcU/39DPTMh8dw0/s1600/ccs5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="90" src="http://3.bp.blogspot.com/_qCRaC01_njU/TJEHB6YcRKI/AAAAAAAAAcU/39DPTMh8dw0/s400/ccs5.png" width="400" /&gt; &lt;/a&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;If everything went well, you should see that if you press the on-board button, the red led will turn on and off.&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;If so, congratulations! You have built your first MSP430 program!&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;Here's the complete code of this example:&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre class="brush: cpp" style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;#include "msp430g2231.h"  //Contains all definitions for registers and built-in functions&amp;nbsp;
int main(void)  //Main program
{
   WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
 
   P1DIR |= BIT0; // Set P1.0 to output and P1.3 to input direction
   P1OUT &amp;amp;= ~BIT0; // set P1.0 to Off
   P1IE |= BIT3; // P1.3 interrupt enabled
   P1IFG &amp;amp;= ~BIT3; // P1.3 interrupt flag cleared
 
   __bis_SR_register(GIE); // Enable all interrupts
 
   while(1) //Loop forever, we'll do our job in the interrupt routine...
   {}
}
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; P1OUT ^= BIT0;&amp;nbsp; // Toggle P1.0
&amp;nbsp;&amp;nbsp;&amp;nbsp; P1IFG &amp;amp;= ~BIT3; // P1.3 interrupt flag cleared
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;That's all for now, if you see any error on this tutorial, please let me know. The next tutorial will focus on Timers and Interrupts.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Happy Coding!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-1641093669859288182?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=kOuy9u9d7vI:CeXzT34XZUg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=kOuy9u9d7vI:CeXzT34XZUg:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=kOuy9u9d7vI:CeXzT34XZUg:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=kOuy9u9d7vI:CeXzT34XZUg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=kOuy9u9d7vI:CeXzT34XZUg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=kOuy9u9d7vI:CeXzT34XZUg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=kOuy9u9d7vI:CeXzT34XZUg:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=kOuy9u9d7vI:CeXzT34XZUg:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=kOuy9u9d7vI:CeXzT34XZUg:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/kOuy9u9d7vI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/kOuy9u9d7vI/msp430-launchpad-tutorial-part-1-basics.html</link><author>noreply@blogger.com (Enrico Garante)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_qCRaC01_njU/TJDjOMup9hI/AAAAAAAAAb0/754_qaPng28/s72-c/ccs2.png" height="72" width="72" /><thr:total>16</thr:total><feedburner:origLink>http://www.egarante.net/2010/09/msp430-launchpad-tutorial-part-1-basics.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-1469721136834424696</guid><pubDate>Sat, 04 Sep 2010 20:42:00 +0000</pubDate><atom:updated>2010-09-18T15:20:27.882+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">electronics</category><category domain="http://www.blogger.com/atom/ns#">review</category><category domain="http://www.blogger.com/atom/ns#">beetlebot</category><title>Solarbotics BeetleBot Review</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hcgIJVWpEa18i8B5YIRpoCQLc1I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hcgIJVWpEa18i8B5YIRpoCQLc1I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hcgIJVWpEa18i8B5YIRpoCQLc1I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hcgIJVWpEa18i8B5YIRpoCQLc1I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;So here it is: yesterday I received a white package from the cool guys at &lt;a href="https://www.solarbotics.com/"&gt;Solarbotics, &lt;/a&gt;and now I'm ready to assemble and review the &lt;a href="http://www.solarbotics.com/products/k_jb/"&gt;BeetleBot&lt;/a&gt;!&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;What is a BeetleBot? Well, as they say at Solarbotics, it&lt;span id="lblDescription"&gt; is "the simplest TRUE robot you can build". And this is true: you only require a screwdriver (included in the kit, wow!) and an hour of your free time to enjoy this clever bot. The BeetleBot goes forward until it hits an obstacle (thanks to the antenna bump-sensors), then he turns around and keeps going in the opposite direction.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://a.imageshack.us/img688/1411/s1051253.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://a.imageshack.us/img688/1411/s1051253.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;span id="lblDescription"&gt;So let's open the box! You'll find: &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; margin-left: 1em; text-align: right;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://a.imageshack.us/img405/8503/s1051237.jpg" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://a.imageshack.us/img405/8503/s1051237.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The kit unboxed.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;ul style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;An acrylic baseplate, top shell, switch spacer &lt;/li&gt;
&lt;li&gt;2x switches&lt;/li&gt;
&lt;li&gt;2x wire antennae&lt;/li&gt;
&lt;li&gt;A power switch harness&lt;/li&gt;
&lt;li&gt; A switch harness&lt;/li&gt;
&lt;li&gt;2x CC Motors&lt;/li&gt;
&lt;li&gt;2x aluminium motor brackets&lt;/li&gt;
&lt;li&gt;2x Rubber Tires &lt;/li&gt;
&lt;li&gt;A piece of double-sided tape &lt;/li&gt;
&lt;li&gt;A tail spring&lt;/li&gt;
&lt;li&gt;2x AAA battery packs&lt;/li&gt;
&lt;li&gt;A bunch of screws &lt;/li&gt;
&lt;li&gt;3x 5/8" nylon spacers &lt;/li&gt;
&lt;li&gt;6x leg wires  &lt;/li&gt;
&lt;li&gt;A stickersheet   &lt;/li&gt;
&lt;li&gt;A screwdriver&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;and of course the instruction manual. &lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;The instruction booklet is very useful and has detailed pictures to help everyone getting this kit well-assembled. This "screw-only" kit is very easy to mount and it doesn't require dangerous and complex soldering, only basic handskills with a screwdriver! Here is the Beetlebot in the early phases of assembling.&lt;br /&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://a.imageshack.us/img237/2776/s1051240.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://a.imageshack.us/img237/2776/s1051240.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The bottom Side&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://a.imageshack.us/img530/2766/s1051238.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="240" src="http://a.imageshack.us/img530/2766/s1051238.jpg" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;The Top side&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;a href="http://a.imageshack.us/img337/9157/s1051241.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://a.imageshack.us/img337/9157/s1051241.jpg" width="320" /&gt;&lt;/a&gt;Here's the BeetleBot after connecting all the wires. They are the only "brain" of this minimal bot. The circuit was originally d&lt;span id="lblDescription"&gt;esigned by Jerome Demers as a science-fair project. The bumper switches make the motors change the battery pack they use, running forward or backwards. It's all well-explained&lt;/span&gt; in the instruction manual.&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;/div&gt;&lt;div class="" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;br /&gt;
After about an hour, my evil BeetleBot was ready to run freely and scare everyone who tries to get in his way!&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;a href="http://a.imageshack.us/img685/2088/s1051246.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://a.imageshack.us/img685/2088/s1051246.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Wow, this bot is really scary. Next time I'll pick the "good" theme of the kit :) . &lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Sometimes the bot kept spinningaround in circle (at first I liked it), but thanks to the troubleshooting section I fixed it at once (one antenna was stuck and kept the switch closed).&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;What I really liked of this bot is that it's well-documented (big pictures, clear instructions and a good sense of humour) and it is really, really easy to mount. This kit is perfect to give as a present to a young boy, he will surely enjoy assembling it and understanding how the bot works, giving him a good start in the big world of robotics.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Finally, here's the BeetleBot in action. I've made a little enclosure to avoid it to run all over the house (this thing is amazingly fast!).&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/5twF3wfZZsY?fs=1&amp;amp;hl=it_IT"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/5twF3wfZZsY?fs=1&amp;amp;hl=it_IT" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;For additional info, go to the &lt;a href="http://www.solarbotics.com/products/k_jb/"&gt;Solarbotics BeetleBot page&lt;/a&gt;.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-1469721136834424696?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=xeHnUOSN0-U:x5eVC0Wvthc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=xeHnUOSN0-U:x5eVC0Wvthc:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=xeHnUOSN0-U:x5eVC0Wvthc:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=xeHnUOSN0-U:x5eVC0Wvthc:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=xeHnUOSN0-U:x5eVC0Wvthc:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=xeHnUOSN0-U:x5eVC0Wvthc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=xeHnUOSN0-U:x5eVC0Wvthc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=xeHnUOSN0-U:x5eVC0Wvthc:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=xeHnUOSN0-U:x5eVC0Wvthc:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/xeHnUOSN0-U" height="1" width="1"/&gt;</description><enclosure type="" url="http://www.solarbotics.com/products/k_jb/" length="0" /><link>http://feedproxy.google.com/~r/egarante/~3/xeHnUOSN0-U/solarbotics-beetlebot-review.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2010/09/solarbotics-beetlebot-review.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-4976811966960672094</guid><pubDate>Sat, 07 Aug 2010 14:37:00 +0000</pubDate><atom:updated>2010-09-23T11:23:38.550+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">personal</category><title>Holidays</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gIMi6sG_U2QLfvBJya7_F9EZTFk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gIMi6sG_U2QLfvBJya7_F9EZTFk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gIMi6sG_U2QLfvBJya7_F9EZTFk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gIMi6sG_U2QLfvBJya7_F9EZTFk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;I will be on holiday for a few weeks, but September will be a great month!&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;I'll post about:&lt;/div&gt;&lt;ul style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;Solarbotics BeetleBot;&lt;/li&gt;
&lt;li&gt;Arduino BlindWalk project;&lt;/li&gt;
&lt;li&gt;MSP430 and generic electronics tutorials.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Happy summer, and stay tuned!&lt;/div&gt;&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.localitalia.eu/images/eventinews/summer.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="246" src="http://www.localitalia.eu/images/eventinews/summer.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-4976811966960672094?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=vwDCVx4xRjQ:tig7fm1qExk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=vwDCVx4xRjQ:tig7fm1qExk:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=vwDCVx4xRjQ:tig7fm1qExk:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=vwDCVx4xRjQ:tig7fm1qExk:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=vwDCVx4xRjQ:tig7fm1qExk:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=vwDCVx4xRjQ:tig7fm1qExk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=vwDCVx4xRjQ:tig7fm1qExk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=vwDCVx4xRjQ:tig7fm1qExk:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=vwDCVx4xRjQ:tig7fm1qExk:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/vwDCVx4xRjQ" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/vwDCVx4xRjQ/holidays.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>0</thr:total><feedburner:origLink>http://www.egarante.net/2010/08/holidays.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6294703911188142008.post-7427788538329873072</guid><pubDate>Thu, 15 Jul 2010 18:13:00 +0000</pubDate><atom:updated>2011-06-22T15:22:01.692+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">msp430</category><category domain="http://www.blogger.com/atom/ns#">launchpad</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><title>Imperial March on TI Launhpad</title><description>&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/-2PeDeJ8BGswupCjXa8xDLnW6GE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-2PeDeJ8BGswupCjXa8xDLnW6GE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/-2PeDeJ8BGswupCjXa8xDLnW6GE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/-2PeDeJ8BGswupCjXa8xDLnW6GE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;UPDATE1&lt;/b&gt;: I've been published on TI's Launchpad page! Check &lt;a href="http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_%28MSP-EXP430G2%29#Cool_Project_Demonstrations.21"&gt;it&lt;/a&gt;  out!&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;b&gt;UPDATE2&lt;/b&gt;: I've posted &lt;a href="http://processors.wiki.ti.com/index.php/Playing_The_Imperial_March"&gt;the  tutorial &lt;/a&gt;for this project on TI Launchpad Wiki.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Here it is: my "Hello World" for Texas Instruments' &lt;a href="http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_%28MSP-EXP430G2%29"&gt;MSP430 Launchpad&lt;/a&gt;. The imperial March played on the MSP430G2231!&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;a href="http://img541.imageshack.us/img541/1386/sound.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="256" src="http://img541.imageshack.us/img541/1386/sound.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;I'll post some tutorials about it in a while.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;h3 style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;span class="mw-headline" style="font-size: small;"&gt; Schematic &lt;/span&gt;&lt;/h3&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;The circuit is really simple to build. Solder the 1KOhm resistor to  the positive lead of the speaker (red wire) and connect it to P1.2 on  the Launchpad. Then connect the black wire to the GND pin on the board. You can even remove the R1, but the sound will be very loud and  annoying, and the speaker may be damaged. You can add a 1K trimmer  instead of the resistor to make the volume adjustable.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="center" style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a class="image" href="http://processors.wiki.ti.com/index.php/File:Imperial_march_schematic.png" style="margin-left: 1em; margin-right: 1em;" title="Schematic for driving the piezo speaker"&gt;&lt;img alt="Schematic for driving the piezo speaker" border="0" height="170" src="http://processors.wiki.ti.com/images/d/d1/Imperial_march_schematic.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=6294703911188142008&amp;amp;postID=7427788538329873072" id="Code" name="Code"&gt;&lt;/a&gt;&lt;/div&gt;&lt;h3 style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;span class="mw-headline" style="font-size: small;"&gt; Code&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Here is the fully commented code for this tutorial. I have ported it to the MSP430G2231 from an Arduino example made by &lt;a class="external text" href="http://www.youtube.com/watch?gl=AU&amp;amp;hl=en-GB&amp;amp;v=uLPGTMISJIY" rel="nofollow" title="http://www.youtube.com/watch?gl=AU&amp;amp;hl=en-GB&amp;amp;v=uLPGTMISJIY"&gt;naneau&lt;/a&gt;. &lt;/div&gt;&lt;blockquote&gt;&lt;div class="csh"&gt;&lt;pre class="brush:cpp"&gt;#include "msp430g2231.h"

#define c 261
#define d 294
#define e 329
#define f 349
#define g 391
#define gS 415
#define a 440
#define aS 455
#define b 466
#define cH 523
#define cSH 554
#define dH 587
#define dSH 622
#define eH 659
#define fH 698
#define fSH 740
#define gH 784
#define gSH 830
#define aH 880

void delay_ms(unsigned int ms )
{
      unsigned int i;
      for (i = 0; i&amp;lt;= ms; i++)
        __delay_cycles(500);
}

void delay_us(unsigned int us )
{
      unsigned int i;
      for (i = 0; i&amp;lt;= us/2; i++) 
        __delay_cycles(1);
}

void beep(unsigned int note, unsigned int delay )
{ 
 int x;  
 long delayAmount = (long)(10000/note);
 long loopTime = (long)((delay*100)/(delayAmount*2));
 for (x=0;x loopTime;x++) 
    {    
        IO_HIGH(P1, BIT2);
        delay_us(delayAmount);
        IO_LOW(P1, BIT2);
        delay_us(delayAmount);
    }  
    delay_ms(20);
}

void march()
{
 beep(  a, 500);
    beep(  a, 500);
    beep(  a, 500);
    beep(  f, 350);
    beep(  cH, 150);  
    beep(  a, 500);
    beep(  f, 350);
    beep(  cH, 150);
    beep(  a, 650);
    delay_ms(150);
    //first bit   

    beep(  eH, 500);
    beep(  eH, 500);
    beep(  eH, 500);   
    beep(  fH, 350);
    beep(  cH, 150);
    beep(  gS, 500);
    beep(  f, 350);
    beep(  cH, 150);
    beep(  a, 650);
    delay_ms(150);
    //second bit...  

    beep(  aH, 500);
    beep(  a, 300);
    beep(  a, 150);
    beep(  aH, 400);
    beep(  gSH, 200);
    beep(  gH, 200); 
    beep(  fSH, 125);
    beep(  fH, 125);    
    beep(  fSH, 250);
    
    delay_ms(250);

    beep(  aS, 250); 
    beep(  dSH, 400); 
    beep(  dH, 200);  
    beep(  cSH, 200);  

    //start of the interesting bit   

    beep(  cH, 125);  
    beep(  b, 125);  
    beep(  cH, 250);  
     
    delay_ms(250);
    
    beep(  f, 125);  
    beep(  gS, 500);  
    beep(  f, 375);  
    beep(  a, 125);
    beep(  cH, 500);
    beep(  a, 375);  
    beep(  cH, 125);
    beep(  eH, 650);
    
    //more interesting stuff (this doesn't quite get it right somehow)   

    beep(  aH, 500);
    beep(  a, 300);
    beep(  a, 150);
    beep(  aH, 400);
    beep(  gSH, 200);
    beep(  gH, 200);
    beep(  fSH, 125);
    beep(  fH, 125);    
    beep(  fSH, 250);

    delay_ms(250);

    beep(  aS, 250);  
    beep(  dSH, 400);  
    beep(  dH, 200);  
    beep(  cSH, 200);  

    //repeat... repeat   

    beep(  cH, 125);  
    beep(  b, 125);  
    beep(  cH, 250);      

    delay_ms(250);

    beep(  f, 250);  
    beep(  gS, 500);  
    beep(  f, 375);  
    beep(  cH, 125);
    beep(  a, 500);   
    beep(  f, 375);   
    beep(  cH, 125); 
    beep(  a, 650); 
     
}

int main( void )
{
   WDTCTL = WDTPW + WDTHOLD;
        P1DIR |= BIT2; // P1.2 output
 while(1)
 {
  march();
  delay_ms(2000);
 }
}
&lt;/pre&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=6294703911188142008&amp;amp;postID=7427788538329873072" id="Theoretical_Background" name="Theoretical_Background"&gt;&lt;/a&gt; &lt;br /&gt;
&lt;h2 style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;span class="mw-headline" style="font-size: small;"&gt; Theoretical Background  &lt;/span&gt;&lt;/h2&gt;&lt;div class="thumb tright" style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a class="image" href="http://processors.wiki.ti.com/index.php/File:Squarewave.jpg" style="margin-left: 1em; margin-right: 1em;" title="A square wave."&gt;&lt;img alt="" border="0" class="thumbimage" height="143" src="http://processors.wiki.ti.com/images/thumb/c/c6/Squarewave.jpg/180px-Squarewave.jpg" width="180" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="thumbinner" style="width: 182px;"&gt;&lt;div class="thumbcaption"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;A Pulse Width Modulation (&lt;a class="external text" href="http://en.wikipedia.org/wiki/Pulse-width_modulation" rel="nofollow" title="http://en.wikipedia.org/wiki/Pulse-width_modulation"&gt;PWM&lt;/a&gt;)  output can be used to play tones on a piezo speaker. With this, musical  scales and simple songs can be played on the piezo speaker. &lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;Piezo speakers operate by the converse &lt;a class="external text" href="http://en.wikipedia.org/wiki/Piezoelectricity" rel="nofollow" title="http://en.wikipedia.org/wiki/Piezoelectricity"&gt;piezoelectric effect&lt;/a&gt;:  when a voltage is applied across the terminals, the piezoelectric  material in the speaker deflects in one direction. Applying an  alternating voltage, such as a square wave, will cause the material to  vibrate and create a sound. A constant voltage will not produce a sound.  Also sine, triangle and sawtooth waves can be used to drive a piezo  speaker, resulting in different pitches of the notes. &lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;As you can see from the code, the beep() function was used to  provide the alternating voltage to drive the speaker. The period (do you  remember delay_us()&amp;nbsp;?) of the sqare wave determines the note that will  be played. &lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;You can have some problems about the clock and timings with this  project, I'm still figuring out the MSP430 Clock System as it is the  first time I use them.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Helvetica Neue&amp;quot;,Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://www.blogger.com/post-edit.g?blogID=6294703911188142008&amp;amp;postID=7427788538329873072" id="Future_Ideas" name="Future_Ideas"&gt;&lt;/a&gt;You can modify this project to play sounds from an SD Card, like it has been done &lt;a class="external text" href="http://www.diylife.com/2008/04/25/make-a-talking-msp430-microcontroller-part-3/" rel="nofollow" title="http://www.diylife.com/2008/04/25/make-a-talking-msp430-microcontroller-part-3/"&gt;here&lt;/a&gt;. (I'm working on it, but the sound is really distorced, I'm still wondering why...)&lt;/div&gt;&lt;object height="385" width="480"&gt;&lt;param name="movie" value="http://www.youtube.com/v/oEx_EgIlvtc&amp;amp;hl=it_IT&amp;amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/oEx_EgIlvtc&amp;amp;hl=it_IT&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6294703911188142008-7427788538329873072?l=www.egarante.net' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/egarante?a=f_xaF9QMvoA:oIZBkO312CM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=f_xaF9QMvoA:oIZBkO312CM:-BTjWOF_DHI"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=f_xaF9QMvoA:oIZBkO312CM:-BTjWOF_DHI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=f_xaF9QMvoA:oIZBkO312CM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=f_xaF9QMvoA:oIZBkO312CM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=f_xaF9QMvoA:oIZBkO312CM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=f_xaF9QMvoA:oIZBkO312CM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/egarante?a=f_xaF9QMvoA:oIZBkO312CM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/egarante?i=f_xaF9QMvoA:oIZBkO312CM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/egarante/~4/f_xaF9QMvoA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/egarante/~3/f_xaF9QMvoA/imperial-march-on-ti-launhpad.html</link><author>noreply@blogger.com (Enrico Garante)</author><thr:total>4</thr:total><feedburner:origLink>http://www.egarante.net/2010/07/imperial-march-on-ti-launhpad.html</feedburner:origLink></item></channel></rss>

