<?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; PICDEM Z</title>
	<atom:link href="http://florent.clairambault.fr/tag/picdem-z/feed" rel="self" type="application/rss+xml" />
	<link>http://florent.clairambault.fr</link>
	<description></description>
	<lastBuildDate>Sat, 04 Feb 2012 19:56:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha-19719</generator>
		<item>
		<title>PIC18 development</title>
		<link>http://florent.clairambault.fr/pic18-development?utm_source=rss&#038;utm_medium=rss&#038;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. 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>
		<item>
		<title>Microchip Zena Analyser &#8211; Zena .zna file format</title>
		<link>http://florent.clairambault.fr/microchip-zena-analyser-zena-zna-file-format?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=microchip-zena-analyser-zena-zna-file-format</link>
		<comments>http://florent.clairambault.fr/microchip-zena-analyser-zena-zna-file-format#comments</comments>
		<pubDate>Thu, 27 Aug 2009 20:58:40 +0000</pubDate>
		<dc:creator>Florent Clairambault</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[802.15.4]]></category>
		<category><![CDATA[Microchip]]></category>
		<category><![CDATA[MiWi]]></category>
		<category><![CDATA[PICDEM Z]]></category>
		<category><![CDATA[Zena]]></category>
		<category><![CDATA[ZigBee]]></category>

		<guid isPermaLink="false">http://florent.clairambault.fr/?p=1327</guid>
		<description><![CDATA[I recently thought that it could be interesting to automatically get everything I needed about a MiWi network using a program reading the .zna capture files. I wanted to check every data sent on the 802.15.4 layer at a higher layer than Zena. But the project has been cancelled, so I won&#8217;t make this program. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently thought that it could be interesting to automatically get everything I needed about a MiWi network using a program reading the .zna capture files. I wanted to check every data sent on the 802.15.4 layer at a higher layer than Zena.</p>
<p>But the project has been cancelled, so I won&#8217;t make this program. But still, I decided to give the format of the file for those who would have the same needs.</p>
<p>everything is Little Endian</p>

<div class="wp_codebox"><table><tr id="p13279"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p1327code9"><pre class="txt" style="font-family:monospace;">[ 4 ] - Frame Number (starting at 0) : 00 00 00 00 is frame 1, 01 00 00 00 is frame 2
[ 4 ] - Time 
[ 1 ] - Length of the frame (remember it counts the 2 last mandatory bytes) 
[ 2 ] - Mac Frame Control
[ 0-125 ] - Frame content
[ 1 ] - RSSI
[ 1 ] - Corr + CRC</pre></td></tr></table></div>

<p>MSB of this last byte describes if the CRC is OK. </p>
<p>In .Net, making this program is pretty easy. You just have to read the first 9 bytes. You will then read the next X (given by the 9th byte) + 3 bytes. Converting these bytes into a readeable message is easy :</p>

<div class="wp_codebox"><table><tr id="p132710"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p1327code10"><pre class="csharp" style="font-family:monospace;">var frameHeader <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">Byte</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span> 
    <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, 
    <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>,
    <span style="color: #FF0000;">4</span>
<span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
var rawFrameNumber <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">Byte</span><span style="color: #008000;">&#91;</span><span style="color: #FF0000;">4</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
Array<span style="color: #008000;">.</span><span style="color: #0000FF;">Copy</span><span style="color: #008000;">&#40;</span>frameHeader, <span style="color: #FF0000;">0</span>, rawFrameNumber, <span style="color: #FF0000;">0</span>, rawFrameNumber<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> 
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #008000;">!</span>BitConverter<span style="color: #008000;">.</span><span style="color: #0000FF;">IsLittleEndian</span><span style="color: #008000;">&#41;</span> <span style="color: #008080; font-style: italic;">// .Net isn't x86 specific</span>
    Array<span style="color: #008000;">.</span><span style="color: #0000FF;">Reverse</span><span style="color: #008000;">&#40;</span>rawFrameNumber, <span style="color: #FF0000;">0</span>, rawFrameNumber<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var frameNumber <span style="color: #008000;">=</span> BitConverter<span style="color: #008000;">.</span><span style="color: #0000FF;">ToUInt32</span><span style="color: #008000;">&#40;</span>rawFrameNumber, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://florent.clairambault.fr/microchip-zena-analyser-zena-zna-file-format/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/19 queries in 0.010 seconds using disk: basic
Object Caching 561/585 objects using disk: basic

Served from: florent.clairambault.fr @ 2012-02-07 11:02:41 -->
