<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BillWSY的生活 &#187; avr</title>
	<atom:link href="http://www.billwsy.com/tag/avr/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.billwsy.com</link>
	<description>BillWSY - 写下我生活中的点滴</description>
	<lastBuildDate>Thu, 01 Dec 2011 09:10:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>开始学习AVR</title>
		<link>http://www.billwsy.com/2010/01/begin-study-avr/</link>
		<comments>http://www.billwsy.com/2010/01/begin-study-avr/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 00:39:03 +0000</pubDate>
		<dc:creator>BillWSY</dc:creator>
				<category><![CDATA[代码如诗]]></category>
		<category><![CDATA[avr]]></category>

		<guid isPermaLink="false">http://www.billwsy.com/?p=35</guid>
		<description><![CDATA[如题，想玩单片机了，大前天买的开发板昨天到了。环境初步定为AVR Studio + WinAVR。第一个程序是点亮LED。



?View Code C#include &#60;avr/io.h&#62;

<span class="readmore"><a href="http://www.billwsy.com/2010/01/begin-study-avr/" title="开始学习AVR">阅读全文——共318字</a></span>]]></description>
			<content:encoded><![CDATA[<p>如题，想玩单片机了，大前天买的开发板昨天到了。环境初步定为AVR Studio + WinAVR。第一个程序是点亮LED。</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p35code3'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p353"><td class="code" id="p35code3"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;avr/io.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    DDRD <span style="color: #339933;">=</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        PORTD <span style="color: #339933;">=</span> <span style="color: #208080;">0b11001010</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>开始的时候老提示我没makefile文件，Google了下才知道，不小心把代码放桌面上了，路径中有中文……</p>
<p>第二个程序是跑马灯，很简单但是还是贴一下吧。也许哪天回头来看会发现当初的代码这么好玩。</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p35code4'); return false;">View Code</a> C</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p354"><td class="code" id="p35code4"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;avr/io.h&gt;</span>
&nbsp;
<span style="color: #993333;">void</span> delay<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #339933;">,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    DDRD <span style="color: #339933;">=</span> <span style="color: #208080;">0xFF</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">char</span> t <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
        PORTD <span style="color: #339933;">=</span> ~t<span style="color: #339933;">;</span>
        delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            t <span style="color: #339933;">&lt;&lt;=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
            PORTD <span style="color: #339933;">=</span> ~t<span style="color: #339933;">;</span>
            delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> delay<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> a<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> b<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> a<span style="color: #339933;">;</span> <span style="color: #339933;">++</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> j <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> b<span style="color: #339933;">;</span> <span style="color: #339933;">++</span> j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            asm<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;NOP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>继续学习去了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.billwsy.com/2010/01/begin-study-avr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

