<?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>Florent Clairambault &#187; PIC18</title>
	<atom:link href="http://florent.clairambault.fr/tag/pic18/feed" rel="self" type="application/rss+xml" />
	<link>http://florent.clairambault.fr</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 23:45:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1-alpha</generator>
		<item>
		<title>PIC18 development</title>
		<link>http://florent.clairambault.fr/pic18-development?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=pic18-development</link>
		<comments>http://florent.clairambault.fr/pic18-development#comments</comments>
		<pubDate>Fri, 30 Oct 2009 10:40:38 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Microchip]]></category>
		<category><![CDATA[PIC18]]></category>
		<category><![CDATA[PICDEM Z]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1251</guid>
		<description><![CDATA[That&#8217;s something I wanted to do for quite a long time now : Creating some programs for PIC chips. I bougth the ICD3 programmer/debugger with the PICDEM Z development kit (for ZigBee communication). I can&#8217;t say it was chip (it costed me 500 €), but I&#8217;ve made a good use of it. The thing is, [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s something I wanted to do for quite a long time now : Creating some programs for PIC chips. I bougth the ICD3 programmer/debugger with the PICDEM Z development kit (for ZigBee communication). I can&#8217;t say it was chip (it costed me 500 €), but I&#8217;ve made a good use of it.</p>
<p>The thing is, it brings me back to my first C programs. It&#8217;s quite hard to come back to some unmanaged, memory limited, namespace less language. I thought the lack of objects would be the hardest part, but in fact it&#8217;s not (you can easily emulate it). The hardest part is the lack of namespace and the massive use of &#8220;#define&#8221;, I really would be happier with a some sort of limited version of C++. The MPLAB development environment is awful (compared to Visual Studio) : no reindenting, no refactoring, no smart-anything. This is WILD for me. It&#8217;s like being a citizen in the jungle.<br />
I took back the old <a href="http://www.doxygen.org">Doxygen</a> to add some pretty doc.</p>
<p>I&#8217;m doing it step by step, 2 to 3 hours some evenings. I started by being able to use the leds, then the buttons, then the serial port (using the UARTIntC library). Recently I added MiWi protocol support. My two chips are connecting to each other and sending messages to each other just fine. </p>
<p>As you can guess, programming this kind of equipment is much less fun than doing some C# .Net. But it has the major advantage of running on very low-cost (less than 4€) chips.</p>
<p>There are some funny things with the Microchip PIC18 Compiler (MCC18).</p>
<p>If you take this code :<br />
<strong>buttons.c : </strong></p>

<div class="wp_codebox"><table><tr id="p12514"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p1251code4"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &quot;buttons.h&quot;</span>
<span style="color: #993333;">void</span> buttons_Task<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Some stuff</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>buttons.h :</strong></p>

<div class="wp_codebox"><table><tr id="p12515"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1251code5"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> buttons_Task<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>It produces this error :</p>

<div class="wp_codebox"><table><tr id="p12516"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p1251code6"><pre class="txt" style="font-family:monospace;">Warning [2058] call of function without prototype</pre></td></tr></table></div>

<p>The reason is that you must declare your prototypes with no arguments with a void. You have to declare it as &#8220;void buttons_Task(void);&#8221;. Well, thank you Microchip for the dumb pre-compiler error messages.</p>
<p>I also discovered that they are two memory (data and program memory).<br />
In one file I had an : &#8220;extern unsigned char *var;&#8221; and in the other one : &#8220;unsigned char var[8];&#8221;. The thing is the compiler doesn&#8217;t throw you any warning but when you will copy data from this variable, you will get some other data. Because the C programs doesn&#8217;t use the same memory in the two cases.<br />
But MCC18 doesn&#8217;t detect this and the debugger doesn&#8217;t help much because it chooses one variable.</p>
]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/pic18-development/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
