<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Embedded Freaks.. &#187; tinyos</title>
	<atom:link href="http://embeddedfreak.wordpress.com/tag/tinyos/feed/" rel="self" type="application/rss+xml" />
	<link>http://embeddedfreak.wordpress.com</link>
	<description>Daily embedded life tips and trick</description>
	<lastBuildDate>Sat, 14 Nov 2009 00:47:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='embeddedfreak.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/9f1113cc5558fcab720e54b7e5a379eb?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Embedded Freaks.. &#187; tinyos</title>
		<link>http://embeddedfreak.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://embeddedfreak.wordpress.com/osd.xml" title="Embedded Freaks.." />
		<item>
		<title>Using NesC without TinyOS</title>
		<link>http://embeddedfreak.wordpress.com/2008/09/23/using-nesc-without-tinyos/</link>
		<comments>http://embeddedfreak.wordpress.com/2008/09/23/using-nesc-without-tinyos/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 09:45:44 +0000</pubDate>
		<dc:creator>kunilkuda</dc:creator>
				<category><![CDATA[WSN]]></category>
		<category><![CDATA[nesc]]></category>
		<category><![CDATA[tinyos]]></category>

		<guid isPermaLink="false">http://embeddedfreak.wordpress.com/?p=142</guid>
		<description><![CDATA[Being avid NesC user for a year makes me understand how powerful this language can be.
It&#8217;s not C++ (or some kind of new OO/Object Oriented language), but it has just enough OO features to support embedded system. C++ / J2ME is complety useless for 8-bits MCU with memory less than 1MByte. It&#8217;s not C, or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=embeddedfreak.wordpress.com&blog=1740165&post=142&subd=embeddedfreak&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Being avid <a href="http://nescc.sourceforge.net/">NesC</a> user for a year makes me understand how powerful this language can be.</p>
<p>It&#8217;s not C++ (or some kind of new OO/Object Oriented language), but it has <em>just enough</em> OO features to support embedded system. C++ / J2ME is complety useless for 8-bits MCU with memory less than 1MByte. It&#8217;s not C, or another kind of <em>portable assembly language</em>, but it&#8217;s quite portable if you know how to design your interface. You can even replace the peripheral / IC drivers within 1 line of code.</p>
<p>My plan is to use NesC components without TinyOS. It will reduce a lot of code size. Hence, the whole program can be stored inside 2kBytes AVR, since the radio (CC2420) is replaced by transparent modem (Maxstream).</p>
<p>And here&#8217;s the thing that I found:</p>
<p><span id="more-142"></span></p>
<p><strong>Minimum Program</strong></p>
<p>#include <avr/io.h></p>
<p>module MainC<br />
{<br />
}<br />
implementation<br />
{<br />
  int main() __attribute__ ((C, spontaneous))<br />
  {<br />
    DDRA  |=  (1 << PA0);<br />
    PORTA &#038;= ~(1 << PA0);<br />
  }<br />
}</p>
<p>The code is simple code to pull low PA0 (yellow LED on Micaz-alike boards).</p>
<p><strong>Compiling with Nesc</strong></p>
<p>How do you compile this module ? Well, here&#8217;s how:</p>
<p># nescc -gcc=avr-gcc -mmcu=atmega128 -Os MainC.nc -o main.elf</p>
<p>Let me explain it a bit. Nesc actually is not a real compiler. It will translate the NesC files (*.nc) into C, then call the C compiler to compile the C files.</p>
<p>The -gcc option tells NesC which C compiler that&#8217;s suppose to be used. The other options (-mmcu=atmega128 ,-Os, -o main.elf) will be passed to the compiler. The only thing that NesC needs is the component&#8217;s name: MainC.nc.</p>
<p>If you want to see its C file, you can use this:</p>
<p># nescc -gcc=avr-gcc -mmcu=atmega128 -conly MainC.nc</p>
<p><strong>Hex File, Listing, etc</strong><br />
Once you get the ELF file, the rest will be easy. You can take a look on AVR libc tutorial <a href="http://www.nongnu.org/avr-libc/user-manual/group__demo__project.html">here</a> to get the hex files, checking the size, generate listing, etc.</p>
<p><strong>Next Step..</strong></p>
<p>Generate you own Makefile, unless you are willing to type all day long.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/embeddedfreak.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/embeddedfreak.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/embeddedfreak.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/embeddedfreak.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/embeddedfreak.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/embeddedfreak.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/embeddedfreak.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/embeddedfreak.wordpress.com/142/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/embeddedfreak.wordpress.com/142/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/embeddedfreak.wordpress.com/142/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=embeddedfreak.wordpress.com&blog=1740165&post=142&subd=embeddedfreak&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://embeddedfreak.wordpress.com/2008/09/23/using-nesc-without-tinyos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/13b3ee554fe96a750148b9819d734843?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">kunilkuda</media:title>
		</media:content>
	</item>
	</channel>
</rss>