<?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>Eugene Hutorny &#187; Projects</title>
	<atom:link href="http://hutorny.in.ua/category/projects/feed" rel="self" type="application/rss+xml" />
	<link>http://hutorny.in.ua</link>
	<description>Programming in a small</description>
	<lastBuildDate>Tue, 16 Mar 2010 07:25:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Simplescope v1.1 released</title>
		<link>http://hutorny.in.ua/projects/w32/sisan/simplescope-v11-released</link>
		<comments>http://hutorny.in.ua/projects/w32/sisan/simplescope-v11-released#comments</comments>
		<pubDate>Wed, 14 Mar 2007 09:08:09 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[SISAN]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/w32/sisan/simplescope-v11-released</guid>
		<description><![CDATA[This is a maintenance release of the product that includes the following fixes: 1. SISAN v 1.1 &#160;&#160;1.1.&#160;Added SISAM88 hardware schematic &#160;&#160;1.2.&#160;Fixed TX/RX typo on SISAM690 schematic &#160;&#160;1.3.&#160;Fixed issue with beam pattern affecting ruler pattern 2. SISAM1 v 1.1 &#160;&#160;2.1.&#160;Fixed diagnostic failure, which made product unusable if high baudrate cannot be set &#160;&#160;2.2.&#160;Fixed issue with [...]]]></description>
			<content:encoded><![CDATA[<p>This is a maintenance release of the product that includes the following fixes:<br />
<strong>1. SISAN v 1.1</strong><br />
&nbsp;&nbsp;1.1.&nbsp;Added SISAM88 hardware schematic<br />
&nbsp;&nbsp;1.2.&nbsp;Fixed TX/RX typo on SISAM690 schematic<br />
&nbsp;&nbsp;1.3.&nbsp;Fixed issue with beam pattern affecting ruler pattern<br />
<strong>2. SISAM1 v 1.1</strong><br />
&nbsp;&nbsp;2.1.&nbsp;Fixed diagnostic failure, which made product unusable if high baudrate cannot be set<br />
&nbsp;&nbsp;2.2.&nbsp;Fixed issue with BREAK is not handled properly<br />
<a id=p97 href="http://hutorny.in.ua/wp-content/uploads/2007/03/Simplescope.v1.1.zip">Download Simplescope v1.1.</a></p>
<p><span id="more-96"></span><br />
Read more about <a href="http://hutorny.in.ua/projects/pic/sisam/sisam-overview">SISAM &#8211; SImple SAMpler</a> and <a href="http://hutorny.in.ua/projects/w32/sisan-overview">SISAN &#8211; SImlpe Signal Analyse</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/w32/sisan/simplescope-v11-released/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MIHA675 &#8211; Multi Input Hall Automaton</title>
		<link>http://hutorny.in.ua/projects/pic/miha675-multi-input-hall-automaton</link>
		<comments>http://hutorny.in.ua/projects/pic/miha675-multi-input-hall-automaton#comments</comments>
		<pubDate>Thu, 07 Dec 2006 15:59:25 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[PIC]]></category>
		<category><![CDATA[VELOOS]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/pic/miha675-multi-input-hall-automaton</guid>
		<description><![CDATA[Previous examples illustrated VELOOS programming aspects. This post provides an example of using object oriented paradigm for designing VELOOS application. Unlike the previous examples which were purely programming exercises, this example is dedicated to a utilitarian home appliance application and provides a &#34;reference design&#34; for VELOOS applications. Example3 &#8211; Designing MIHA &#8211; Multi Input Hall [...]]]></description>
			<content:encoded><![CDATA[<p>Previous examples illustrated VELOOS  programming aspects. This post provides an example of using object oriented  paradigm for designing VELOOS application. Unlike the previous examples which  were purely programming exercises, this example is dedicated to a utilitarian  home appliance application and provides a &quot;reference design&quot; for  VELOOS applications.</p>
<p><span id="more-87"></span></p>
<h2>Example3 &ndash; Designing MIHA &ndash;  Multi Input Hall Automaton</h2>
<p></p>
<h3>Introduction</h3>
<p>There are two common approaches for light  switching in halls and staircases &ndash; off-timers and intermediate switching  schemes (please excuse me if terminology is wrong). Off timers turn light on when user pushes a button and turn off when specified time elapsed. Intermediate  switching schemes toggle lights when user toggles any switch (of two). Each  approach has its own advantages and disadvantages, however, both approaches  require special switches, which could be an undesired constraint for interior  design. See, for example, <a href="http://www.o2m8.com/modules.php?name=News&amp;file=article&amp;sid=32">Intermediate lighting switch</a>,&nbsp;<a href="http://www.tlc-direct.co.uk/Manufacturers/Contactum_Distribution/CMD_Controls_3/index.html">Stair case timer</a>,&nbsp;<a href="http://www.amidata.es/componentes-electronicos-es/circuitos-electricos/424356720-STAIRCASE-TIMER.html">Multifunction staircase timer</a></p>
<h3>Requirements (user&#8217;s needs)</h3>
<p>Implement a light-control appliance that:</p>
<ul>
<li>combines off-timer and  intermediate switchers</li>
<li>provides support for at least 3  switches</li>
<li>supports regular light switches  as well as push-buttons</li>
<li>provides settable 0.5-10 min  timer range with a simple user interface for entering value</li>
</ul>
<h3>MIHA Design Description</h3>
<p><u>Key Design Decisions:</u></p>
<ul>
<li>Implement the appliance (named  MIHA) as a VELOOS application running on a PIC microcontroller</li>
<li>Store application  configuration in EEPROM during device programming</li>
<li>Use potentiometer for  specifying timeout</li>
</ul>
<p><u>Architecture</u><br />
  MIHA consists of the following units (see  architecture diagram on Figure 1):</p>
<table border="1" cellspacing="0" cellpadding="0" style="border:solid gray .5pt;border-collapse:collapse;">
<tr>
<td width="196" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">
      Multi-input Switch Debouncer </td>
<td width="463" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Reads and debounces switches, sends a    message on switch state changing. <br />
      Featuring triple port read with majority    logic and software implementation of RC-integration and Schmidt trigger.</td>
</tr>
<tr>
<td width="196" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Hall Light Automaton</td>
<td width="463" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Implements automaton logic, provides    supports for switches/push-buttons, send &#8216;alt&#8217; message to actuator and &#8216;off&#8217;    message to the delay block</td>
</tr>
<tr>
<td width="196" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Delay Time Input</td>
<td width="463" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Reads potentiometer value and sends the    value read to the delay block<br />
      Featuring support for multiple channels.    ADC access is arbitrated via time quantization</td>
</tr>
<tr>
<td width="196" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Message Delay Block</td>
<td width="463" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Provides delay for the &#8216;off&#8217; message.</td>
</tr>
<tr>
<td width="196" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Discrete Actuator</td>
<td width="463" valign="top" style="border:solid gray .5pt;padding:0cm 4pt 0cm 4pt;">Turns on or off an output pin depending    on the message received</td>
</tr>
</table>
<table>
<tr>
<td rowspan="2">
<p><u>Mapping Architecture to Implementation.</u><br />
  Mapping from architectural units to  implementation units is straightforward &ndash; all MIHA units are directly mapped to  operating system objects, inter-unit communications are mapped to messaging. <br />
  All MIHA objects are configurable with  EEPROM data. To make design flexible, object configuration embeds acceptor  handle. The latter two decisions establish a generality which is captured as  two abstract classes:<br />
  PDO &ndash; a configurable Process Data Object<br />
  PDD &ndash; a dynamically bound PDO<br />
  (See class diagram on Figure 2)</p>
</td>
<td rowspan="2">&nbsp;</td>
<td height=57><a href="http://hutorny.in.ua/wp-content/uploads/2006/12/MIHA-Architecture.png" target=_blank rel="thumbnail"><img src="http://hutorny.in.ua/wp-content/uploads/2006/12/MIHA-Architecture.thumbnail.png" alt="MIHA Architecture" height=57 border="0" id="MIHAArchitecture"/></a><br />Figure 1.</td>
</tr>
<tr>
<td><a href="http://hutorny.in.ua/wp-content/uploads/2006/12/MIHA-ClassDiagram.png" target=_blank rel="thumbnail"><img src="http://hutorny.in.ua/wp-content/uploads/2006/12/MIHA-ClassDiagram.thumbnail.png" alt="MIHA Class Diagram" name="image89" height=80 border="0" id="image89" /></a><br />Figure 2.</td>
</tr>
</table>
<h3>Moduling</h3>
<p>Major advantage provided by VELOOS is  ability to design and implement loosely coupled objects. The following practice  can be applied to get full advantage of loose coupling: </p>
<ul>
<li>A unit should be made up of (at  least) two files: (1) .inc containing interface and (2) .asm &ndash; implementation</li>
<li>Each unit should implement one  class or a hierarchy of closely related classes.</li>
<li>A unit should not instantiate  objects of reenterable or configurable classes. Instead it should publish class  name in the interface.</li>
<li>A unit may instantiate object  of a non-reenterable class. In this case it should publish object name and  encapsulate class name.</li>
</ul>
<h3>Sharing RAM among objects</h3>
<p>Decoupling objects via messaging mechanism  provides a very explicit and straightforward watershed for scoping variables &ndash; everything  that should survive between two messages is a part of object state and should  be allocated in udata section, everything that may be discarded after handling  the message is a temporary variable and can be allocated in udata_ovr section.</p>
<h3>Using Timer for Resource Access Arbitration</h3>
<p>Class Potentiometer Parameter Input (PPI)  implements time-quantified approach for sharing ADC among several instances &ndash; time  is sliced on N quants, each instance may access hardware only if TIME mod N  equals to channel number. To simplify computing TIME mod N, N can be chosen as  power of 2. In this example N = 16.</p>
<table>
<tr>
<td rowspan="4">
<h3>Multi-input Debouncer</h3>
<p>On timer event Debouncer  polls the port three times in a row and applies majority logic to determine current  switch state. This approach eliminates sporadic spikes than may be present in a  noisy environment. For each assigned pin it maintains a counter. This counter  is incremented whenever pin level is high and decremented if low. Counter is  maintained in range 0..16, e.g. when it reaches the boundary it is not changed.  When counter reaches upper threshold (12) logical output state is changed to 1  and to 0 when it reaches lower threshold. This is a software model of an RC-integration  connected to a Schmidt trigger.<br />Few samples of  switch bouncing are shown on figures on right. The switches are regular light switches  manufactured by VIKO.</p>
<h3>Hardware Schematic</h3>
<p>MIHA schematic is shown on Figure 6. Relay, loaded on PIC12, should have actuating current up to 25 mA. Resistors R1-R4 are used for pull-up and can be roughly 1 kOhm. In an environment with strong EMI their can be reduced to avoid pickup.</p>
<h3>Package Content</h3>
<p>The package includes three projects to build this application for three different devices &ndash; PIC12F675, PIC16F690, PIC18F248. It is licensed to public under the <a href="http://www.opensource.org/licenses/osl-3.0.php">Open Software   License<br />
</a><a id=p94 href="http://hutorny.in.ua/wp-content/uploads/2006/12/miha.v.1.0.zip">Download MIHA Sources v.1.0</a></p>
</td>
<td rowspan="4">&nbsp;</td>
<td><a href="http://hutorny.in.ua/wp-content/uploads/2006/12/ON-Bouncing.png" target="_blank" rel="thumbnail"><img src="http://hutorny.in.ua/wp-content/uploads/2006/12/ON-Bouncing.thumbnail.png" alt=ON-Bouncing.png height=39 border="0" id="image91" /></a><br />Figure 3.</td>
</tr>
<tr>
<td><a href="http://hutorny.in.ua/wp-content/uploads/2006/12/OFF-Bouncing.png" target="_blank" rel="thumbnail"><img src="http://hutorny.in.ua/wp-content/uploads/2006/12/OFF-Bouncing.thumbnail.png" alt=OFF-Bouncing.png height=39 border="0" id="image92" /></a><br />Figure 4.</td>
</tr>
<tr>
<td><a href="http://hutorny.in.ua/wp-content/uploads/2006/12/Debounced.png" target="_blank" rel="thumbnail"><img src="http://hutorny.in.ua/wp-content/uploads/2006/12/Debounced.thumbnail.png" alt=Debounced.png height=47 border="0" id="image93" /></a><br />Figure 5.</td>
</tr>
<tr>
<td><a href="http://hutorny.in.ua/wp-content/uploads/2006/12/MIHA675.png" target="_blank" rel="thumbnail"><img src="http://hutorny.in.ua/wp-content/uploads/2006/12/MIHA675.thumbnail.png" alt="MIHA Hardware Schematics" height=92 border="0" id="image90" /></a><br />Figure 6.</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/pic/miha675-multi-input-hall-automaton/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VELOOS Example 3</title>
		<link>http://hutorny.in.ua/projects/pic/veloos/veloos-example-3</link>
		<comments>http://hutorny.in.ua/projects/pic/veloos/veloos-example-3#comments</comments>
		<pubDate>Wed, 06 Dec 2006 21:38:00 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[VELOOS]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/pic/veloos/veloos-example-3</guid>
		<description><![CDATA[This example for PIC12F675 implements set of &#8220;actuators&#8221; and &#8220;generators&#8221; controlled via USART. Actuators produce one 300 ms pulse when it receives command &#8216;ON&#8217; and three 100 ms pulses delimited with 100 ms spaces (pauses) on command &#8216;OFF&#8217;. Generators, when turned on, produce pulses and spaces of the specified duration (1..255). Actuators and Generators are [...]]]></description>
			<content:encoded><![CDATA[<p>This example for PIC12F675 implements set of &#8220;actuators&#8221; and &#8220;generators&#8221; controlled via USART. Actuators produce one 300 ms pulse when it receives command &#8216;ON&#8217; and three 100 ms pulses delimited with 100 ms spaces (pauses) on command &#8216;OFF&#8217;. Generators, when turned on, produce pulses and spaces of the specified duration (1..255). </p>
<p><span id="more-84"></span></p>
<p>Actuators and Generators are implemented as instances of Actuator and Generator classes. Yet another class in this example   protocol driver   parses the incoming via software USART commands and forwards it to a corresponding object. Command format is: <strong>command</strong>[<strong>data</strong>,[<strong>data</strong>]]; COM port settings: 2400, 8bit no parity, 1 stop bits.<br />
USART is implemented in software and uses INT0 and TMR1 interrupts for timing bits.<br />
Command language consist of 8 commands (H..O)</p>
<ul>
<li>H,I,J   control an actuator, </li>
<li>K,L   control a generator, </li>
<li>N   all actuators do OFF, susped all generators</li>
<li>O   all actuators do ON, resume all generators.</li>
</ul>
<p>H,I,J commands accepts &#8217;0&#8242; and &#8217;1&#8242; as a parameter to execute OFF or ON command  respectively. K,L commands should be supplied with pulse and pause duration</p>
<p>For example:</p>
<ul>
<li>H0   Actuator 1 do OFF</li>
<li>LUA   Turn on generator 1 with 85 ms pulse and 65 ms space</li>
</ul>
<p><a id=p86 href="http://hutorny.in.ua/wp-content/uploads/2006/12/Example3.zip">Example 3 Sources</a></p>
<p>Hardware Scematics. Connect loads to GP0,GP1,GP4,GP5 (not shown on the schematic)</p>
<p><img id="image85" alt="Example 3 Hardware Schematics" src="http://hutorny.in.ua/wp-content/uploads/2006/12/Example3.png" /></p>
<p>Simulation Results</p>
<p><img id="image95" alt="Simulation Results" src="http://hutorny.in.ua/wp-content/uploads/2006/12/SIM-Example3.png" /></p>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/pic/veloos/veloos-example-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VELOOS 1.0 released</title>
		<link>http://hutorny.in.ua/projects/pic/veloos/veloos-10-released</link>
		<comments>http://hutorny.in.ua/projects/pic/veloos/veloos-10-released#comments</comments>
		<pubDate>Mon, 20 Nov 2006 18:02:45 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[VELOOS]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/pic/veloos/veloos-10-released</guid>
		<description><![CDATA[VELOOS is an object-oriented message-triggered cooperative operating system for 8-bit Microchip microcontrollers licensed to public under the Open Software License Release 1.0 includes VELOOS kernel and two timer drivers (TMR0 and TMR2 based). It has been tested on the following devices: PIC12F675, PIC16F690, PIC18F248. Download VELOOS v.1.0 Supporting other 14-bit core and 16-bit core devices [...]]]></description>
			<content:encoded><![CDATA[<p>VELOOS is an object-oriented message-triggered cooperative operating system for 8-bit Microchip microcontrollers licensed to public under the <a href="http://www.opensource.org/licenses/osl-3.0.php">Open Software License</a><br />
Release 1.0 includes VELOOS kernel and two timer drivers (TMR0 and TMR2 based). It has been tested on the following devices: PIC12F675, PIC16F690, PIC18F248.</p>
<p><a id=p83 href="http://hutorny.in.ua/wp-content/uploads/2006/11/veloos_v1_0.zip">Download VELOOS v.1.0</a></p>
<p><span id="more-82"></span></p>
<h3>Supporting other 14-bit core and 16-bit core devices</h3>
<p>By design, VELOOS allocates its message at the end of available banked (e.g. not shared) memory. Unfortunately, standard .inc does not include constants defining memory limits, therefore pic.inc refines &#8220;device model&#8221; and this refinement block has to be provided for each device to be used for a VELOOS application.</p>
<p>
<code><br />
&nbsp;ifdef __16F690<br />
&nbsp;&nbsp;include         "p16f690.inc"<br />
&nbsp;&nbsp;include         "pic16.inc"<br />
&nbsp;&nbsp;_pic&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;= _pic16F690<br />
&nbsp;&nbsp;_pic_maxram&nbsp;&nbsp;&nbsp;&nbsp;= 016Fh       ; with shared bank excluded<br />
&nbsp;&nbsp;_pic_maxrom&nbsp;&nbsp;&nbsp;&nbsp;= 0FFFh<br />
&nbsp;&nbsp;_pic_maxeeprom&nbsp;= 0FFh<br />
&nbsp;endif<br />
</code></p>
<p>With this refinement, VELOOS is expected to work for any 16-bit core devices (PIC18), and any 14-bit core (most of PIC14 and some of PIC12). Perhaps, it may also work on 12-bit core (PIC10 and some of PIC12). However, since there are no interrupts, timer drivers can not be used. Also, these devices have severe memory constraints, which make use of OS unreasonable.</p>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/pic/veloos/veloos-10-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VELOOS Example 2</title>
		<link>http://hutorny.in.ua/projects/pic/veloos/veloos-example-2</link>
		<comments>http://hutorny.in.ua/projects/pic/veloos/veloos-example-2#comments</comments>
		<pubDate>Wed, 15 Nov 2006 15:30:06 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[VELOOS]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/pic/veloos/veloos-example-2</guid>
		<description><![CDATA[This post continues series of examples and describes how VELOOS can be used for implementing time-triggered applications. Example2 &#8211; Heartbeat Driven PDO Design&#160;idea: Enhance previous example with a timer and two PDOs processing timer messages. Use EEPROM to keep instance-specific data. Value: Gives a simple example of implementing (1) time-triggered PDOs, (2) reenterable classes. Implements [...]]]></description>
			<content:encoded><![CDATA[<p>This post continues series of examples and describes how VELOOS can be used for implementing time-triggered applications.</p>
<p><span id="more-78"></span></p>
<h2>Example2 &#8211; Heartbeat Driven PDO</h2>
<p></p>
<table id="Table1" style="BORDER-COLLAPSE: collapse" cellSpacing="2" cellPadding="2" border="0">
<tr>
<td vAlign="top" align="right" width="111"><b>Design&nbsp;idea:</b></td>
<td vAlign="top" width="576">Enhance previous example with a timer and two PDOs processing timer messages. Use EEPROM to keep instance-specific data.</td>
</tr>
<tr>
<td vAlign="top" align="right" width="111"><b>Value:</b></td>
<td vAlign="top" width="576">Gives a simple example of implementing (1) time-triggered PDOs, (2) reenterable classes. Implements a class which may be used for debug purposes to watch system &quot;heartbeat&quot;. </td>
</tr>
</table>
<h3>Design Description</h3>
<p>This sample application implements two PDO each triggering port pin with a certain period: first PDO is on 1 sec period, second &#8211; on 1 ms. Since behavioral pattern of these PDO are the same, they were implemented as instances of the same class.</p>
<h3>Deploying VELOOS Timer Driver</h3>
<p>Timer Driver is a non-reenterable encapsulated PDO with an interrupt handler and internal counters for millisecond and seconds. To deploy a timer driver to VELOOS application, the project should include file vtm0.asm (Timer0 based) or vtm2.asm (Timer2 based). Timer constants are calculated automatically based on <code>_osc_clock</code>. Timer driver configures hardware timer for 1 ms interrupts. When a timer interrupts occurs, Interrupt Handler sends a broadcast message. Timer PDO counts 1ms messages and on every 1000-th broadcasts a 1s message. Both 1 ms and 1 s messages include current time value.</p>
<p>In a pseudo language messages can be declared as the following (acceptor field is not shown):</p>
<table border="1" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border:none;">
<tr>
<td width="358" valign="top" style="border:solid windowtext 1.0pt;padding:0cm 5.4pt 0cm 5.4pt;"><code>struct VTMR_cMsgTimer1ms {&nbsp;<br />&nbsp;    byte&nbsp;&nbsp;&nbsp; msg_id;<br />
&nbsp;    word&nbsp;&nbsp;&nbsp; millisec; }<br /></code></td>
<td width="359" valign="top" style="border:solid windowtext 1.0pt;border-left:none;padding:0cm 5.4pt 0cm 5.4pt;"><code>&nbsp;struct VTMR_cMsgTimer1s {<br />
&nbsp;&nbsp;    byte&nbsp;&nbsp;&nbsp; msg_id;<br />
&nbsp;&nbsp;    word&nbsp;&nbsp;&nbsp; seconds; }</code></td>
</tr>
</table>
<p></p>
<h3>Handling Timer Messages</h3>
<p>Timer messages are regular VELOOS messages.  To handle a timer message, PDO should first recognize the message and then, if necessary, examine time delivered with the message and take appropriate action:</p>
<p><code style="text-align:left">MyHandler&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; FSR points to message ID field</span><br />
&nbsp;&nbsp;&nbsp; movlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b><span style="COLOR: #333399">VTMR_cMsgIDTimer1ms</span></b><br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  INDF, W&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; if message.msg_id &lt;&gt; VTMR_cMsgIDTimer1ms</span><br />
&nbsp;&nbsp;&nbsp; skpz<br />
&nbsp;&nbsp;&nbsp; return&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; return</span><br />
&nbsp;&nbsp;&nbsp; incf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  FSR, F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; make FSR pointing to LSB of message data</span><br />
&nbsp;&nbsp;&nbsp; movf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  INDF, W<br />
&nbsp;&nbsp;&nbsp; andlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  0F0h<br />
&nbsp;&nbsp;&nbsp; xorlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  007h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; on 7-th msec of every 16 msec</span><br />
&nbsp;&nbsp;&nbsp; skpnz<br />
&nbsp;&nbsp;&nbsp; return<br />
&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; do something</span><br />
  </code>
</p>
<h3>Targeting Reenterability</h3>
<p>To make a class reenterable, it should not be build-time-bound to any resource. This sample class achieves reenterability by using <i>This</i> as a pointer to EEPROM data with configuration (message ID, port mask) assigned to a particular class instance. In run-time PDO reads data from EEPROM on per need basis (e.g. does not cache in in registers). Since message ID is also stored in EEPROM, message handler first reads message ID from EEPROM and then message is processed:</p>
<p><code style="text-align:left">TmrHandler<br />
&nbsp;&nbsp;&nbsp; movf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b><span style="COLOR: #333399">This</span></b>, W<br />
&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;EE_read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">;  W = EEPROM[This]; //(== msgid)</span><br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  INDF, W<br />
&nbsp;&nbsp;&nbsp; skpz<br />
&nbsp;&nbsp;&nbsp; return<br /></code></p>
<p>With this design, class should be properly instantiated, e.g. object data should point to the configuration location in EEPROM. This can be achieved with use of a label, placed in EEPROM section:</p>
<p><code style="text-align:left">DEEPROM code<br />
On1mSecData&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; Configuration name</span><br />
&nbsp;&nbsp; de&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b><span style="COLOR: #333399">VTMR_cMsgIDTimer1ms</span></b>, .1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span style="COLOR: green">; Configuration data</span><br />
<b><span style="COLOR: #333399">VOS_Objects</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; Object registry begins</span><br />
On1mSec&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; Object name (not necessary for this example)</span><br />
&nbsp;&nbsp; <b><span style="COLOR: #333399">VOS_mPersistentObject</span></b> MyTimer, On1mSecData <span style="COLOR: green">; Instance on MyTimer constructed with</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: green">;object data pointing  to configuration</span></code></p>
<h3>Building the project</h3>
<p>All classes and objects for this example (except Timer) are declared, implemented and instantiated in one file: main.asm. Although this is not a recommended practice, this example, for simplicity, gives it this way. Moduling aspects will be discussed in a subsequent example.</p>
<p>A package with sources for this example can be downloaded <a href="http://hutorny.in.ua/wp-content/uploads/2006/11/VELOOS-Example2.zip">on this link</a>. It includes the following files:</p>
<table id="Table3" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellSpacing="0" cellPadding="0" border="1">
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>Example2.mcp</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">MP LAB project file</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>main.asm</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">Example2 application sources</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>pic.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">Processor-specific primitives, macros and includes</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>pic16.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">PIC16/PIC12 specific primitives</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vos.asm</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS kernel</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vos.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS public interface</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vos_cfg.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS configuration file</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vtm2.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">Timer public interface</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vtm2_m.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">Timer auxiliary macros</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vtm2.asm</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">Timer implementation</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>16f690.lkr</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS specific linker script</td>
</tr>
</table>
<p><a href="http://hutorny.in.ua/wp-content/uploads/2006/11/VELOOS-Example2.zip">Download sources</a></p>
<table>
<tr>
<td rowspan="2">
<h3>Running the application</h3>
<p>This application was loaded to PIC16F690 on &quot;Low  Pin Count Demo Board&quot; supplied with PICkit&trade; 2. Activity of 1s driven object can be visually monitored with a led. Activities of other objects (1ms  and self-triggering) can be monitored aurally, for example  by connecting a  headset, or with a scope. Signals from RC2 and RC3 were captured with  Simplescope and their traces are shown on Figure 1 and Figure 2. As results  show, in the first run 1 ms period was actually shorter&nbsp; &#8211; 970 us instead of 1000. Therefore, for the  next run internal oscillator has been tuned with -4 value. Traces indicate that  1 ms period varies 1000-1080 ms &ndash; this is an expected effect of message  queuing.</p>
</td>
<td>&nbsp;</td>
<td width=90 align="center"><a target=_blank href="http://hutorny.in.ua/wp-content/uploads/2006/11/Example2-Timing.png" rel="thumbnail"><img src="http://hutorny.in.ua/wp-content/uploads/2006/11/Example2-Timing.thumbnail.png" alt="Timing of sampled signals" name="image80" height=37 border="0" id="image80" /></a><br />
  Figure 1</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center"><a target=_blank href="http://hutorny.in.ua/wp-content/uploads/2006/11/Example2-Timing2.png" rel="thumbnail"><img id="image81" height=37 alt="Timing of sampled signals (adjusted)" src="http://hutorny.in.ua/wp-content/uploads/2006/11/Example2-Timing2.thumbnail.png" /></a><br />
      <span align="center">Figure 2</span></td>
</tr>
</table>
<h3>Application Source</h3>
<p><code style="text-align:left">&nbsp;<br /><span style="COLOR: green">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; License:&nbsp;&nbsp; Licensed to public under the Open Software License</span><br /><span style="COLOR: green">;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.opensource.org/licenses/osl-3.0.php"><span style="COLOR: green; TEXT-DECORATION: none; text-underline: none">http://www.opensource.org/licenses/osl-3.0.php</span></a><br />&nbsp;include "pic.inc"<br />&nbsp;include "vos.inc"<br />&nbsp;<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
&nbsp;__CONFIG&nbsp;_WDT_ON&nbsp;&amp;&nbsp;_INTRC_OSC_NOCLKOUT&nbsp;&amp;&nbsp;_CP_OFF&nbsp;&amp;&nbsp;_PWRTE_ON &amp;&nbsp;_MCLRE_ON&nbsp;&amp;&nbsp;_FCMEN_OFF&nbsp;&amp;&nbsp;_BOR_OFF&nbsp;&amp;&nbsp;_IESO_OFF<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
&nbsp;<br />
&nbsp;constant mask&nbsp;&nbsp;= 02h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; mask to be used for driving port (RA1)</span><br />
&nbsp;constant msgid = 040h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; message ID</span><br />
&nbsp;constant mask1ms&nbsp;= 04h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; mask to be used for driving port on 1 msec event (RC2)</span><br />
&nbsp;constant mask1s&nbsp;&nbsp;= 08h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; mask to be used for driving led  (RC3) &nbsp;</span><br />
  <b><span style="COLOR:#333399">VOS_Classes</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Class definitions begin</span><br />
  MyClass <b><span style="COLOR: #333399">VOS_mClass</span></b> MyHandler,&nbsp;MyInit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; MyClass implementes MyHandler and MyInit methods</span><br />
  MyTimer <b><span style="COLOR: #333399">VOS_mClass</span></b> TmrHandler, TmrInit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; MyTimer implementes TmrHandler, TmrInit</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Class definitions end with beginning of the next code section</span><br />
  <b><span style="COLOR:#333399">VOS_Objects</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Object registry begins</span><br />
MyObject<br />
&nbsp; <b><span style="COLOR:#333399">VOS_mPersistentObject</span></b>&nbsp;MyClass,&nbsp;mask&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<span style="COLOR: green">; Instance of MyClass constructed with object data == mask</span><br />
On1mSec<br /> <br />
&nbsp; <b><span style="COLOR:#333399">VOS_mPersistentObject</span></b> MyTimer,On1mSecData<span style="COLOR: green">; Instance on MyTimer constructed with object data pointing</span><br /> <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; to EERPOM location</span><br />
On1Sec<br />
&nbsp;  <b><span style="COLOR:#333399">VOS_mPersistentObject</span></b> MyTimer,On1SecData  <span style="COLOR: green">; Another instance on MyTimer</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Object registry ends with beginning of the code next section</span><br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
  <br />
  DEEPROM code<br />
On1mSecData     <br />
&nbsp; de      <b><span style="COLOR:#333399">VTMR_cMsgIDTimer1ms</span></b>, mask1ms<br />
On1SecData<br />
&nbsp; de      <b><span style="COLOR:#333399">VTMR_cMsgIDTimer1s</span></b>, mask1s<br />
  <span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
  &nbsp;&nbsp;&nbsp; code  <br />
MyInit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; This was loaded with object data</span><br />
&nbsp;&nbsp;&nbsp; comf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="COLOR:#333399">This</span></b>,&nbsp;W&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; W := ~mask</span><br />
  <br />
  &nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp; TRISA<br />&nbsp;&nbsp;&nbsp; movwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRISA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Prepare port for output</span><br />&nbsp;&nbsp;&nbsp; <b><span style="COLOR:#333399">VOS_mPostMessage</span></b>&nbsp;MyObject,&nbsp;msgid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; post message to itself</span><br />
&nbsp;&nbsp;&nbsp; return<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />&nbsp;<br />
MyHandler&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; FSR points to message ID field, This is loaded with object data</span><br />&nbsp;&nbsp;&nbsp; movlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msgid<br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INDF,&nbsp;W&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; if message.msg_id &lt;&gt; msgid</span><br />
&nbsp;&nbsp;&nbsp; skpz<br />
&nbsp;&nbsp;&nbsp; return&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; return</span><br />
&nbsp;&nbsp;&nbsp; movf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span style="COLOR: #333399">This</span></b>,&nbsp;W<br />&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp; PORTA<br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PORTA,&nbsp;F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Toggle port</span><br />
&nbsp;&nbsp;&nbsp; <b><span style="COLOR: #333399">VOS_mPostMessage </span></b>MyObject,&nbsp;msgid&nbsp;&nbsp; &nbsp; &nbsp; <span style="COLOR: green">; post message to itself</span><br />
&nbsp;&nbsp;&nbsp; return<br /><span style="COLOR: green">;------------------------------------------------------------------------------</span></p>
<p>EE_read<br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp;  EEADR<br />
&nbsp;&nbsp;&nbsp; movwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  EEADR&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green; ">; EEADDR = This</span><br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp;  EECON1<br />
&nbsp;&nbsp;&nbsp; bsf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  EECON1,&nbsp;RD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green; ">; EE Read</span><br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp;  EEDATA<br />
&nbsp;&nbsp;&nbsp; movfw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  EEDATA <br />
&nbsp;&nbsp;&nbsp; return<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
&nbsp;<br />
TmrHandler<br />
&nbsp;&nbsp;&nbsp; movf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b><span style="COLOR: #333399">This</span></b>, W<br />
&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  EE_read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green; ">; W = EEPROM[This] == msgid</span><br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  INDF, W<br />
&nbsp;&nbsp;&nbsp; skpz<br />
&nbsp;&nbsp;&nbsp; return<br />
&nbsp;&nbsp;&nbsp; incf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b><span style="COLOR: #333399">This</span></b>, W<br />
&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  EE_read&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green; ">; W = EEPROM[This+1] == mask</span><br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp;  PORTC<br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  PORTC, F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green; ">; Toggle   PORT</span><br />
&nbsp;&nbsp;&nbsp; return&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span></p>
<p>TmrInit<br />
&nbsp;&nbsp;&nbsp; incf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <b><span style="COLOR: #333399">This</span></b>, W<br />
&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  EE_read&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:green; ">; W =  EEPROM[This+1] == mask</span><br />
&nbsp;&nbsp;&nbsp; xorlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  0FFh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green; ">; W = ~mask</span><br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp;  TRISC<br />
&nbsp;&nbsp;&nbsp; andwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  TRISC, F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color:green; ">; Prepare port for output according to mask</span><br />
&nbsp;&nbsp;&nbsp; return<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
&nbsp;<br />
<b><span style="COLOR: #333399">VOS_BootHandlers</span></b> code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; starts a section for the application boot handler</span><br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp; ANSEL<br />
&nbsp;&nbsp;&nbsp; clrf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ANSEL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;<span style="COLOR: green">; Turn all pints to digital</span><br />
&nbsp;&nbsp;&nbsp; clrf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ANSELH<br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp; OSCCON&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Set Fosc = 8Mhz</span><br />
&nbsp;&nbsp;&nbsp; movlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (.7 &lt;&lt; IRCF0)<br />
&nbsp;&nbsp;&nbsp; movwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OSCCON<br />
&nbsp;&nbsp;&nbsp; banksel     &nbsp;&nbsp;&nbsp; OSCTUNE     <br />
&nbsp;&nbsp;&nbsp; movlw&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; -.4<br />
&nbsp;&nbsp;&nbsp; movwf&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; OSCTUNE <br />
&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; !!! NO RETURN ALLOWED !!!</span><br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
&nbsp;<br />
&nbsp;end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/pic/veloos/veloos-example-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VELOOS Example 1</title>
		<link>http://hutorny.in.ua/projects/pic/veloos/veloos-example-1</link>
		<comments>http://hutorny.in.ua/projects/pic/veloos/veloos-example-1#comments</comments>
		<pubDate>Fri, 10 Nov 2006 14:17:15 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[VELOOS]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/pic/veloos/veloos-example-1</guid>
		<description><![CDATA[The previous post gave a brief introduction to VELOOS design idea. VELOOS assumes that an application is decomposed on PDOs (Process Data Objects). This post describes by example features provided by VELOOS for implementing PDO. Self-triggering PDO Design&#160;idea: Implement a PDO sending a message to itself. On every message received toggle a pin. Value: Provides [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://hutorny.in.ua/projects/pic/very-low-overhead-operating-system">previous post</a> gave a brief introduction to VELOOS design idea. VELOOS assumes that an application is decomposed on PDOs (Process Data Objects). This post describes by example features provided by VELOOS for implementing PDO.</p>
<p><span id="more-75"></span></p>
<h2>Self-triggering PDO</h2>
<p></p>
<table id="Table1" style="BORDER-COLLAPSE: collapse" cellSpacing="2" cellPadding="2" border="0">
<tr>
<td vAlign="top" align="right" width="111"><b>Design&nbsp;idea:</b></td>
<td vAlign="top" width="576">Implement a PDO sending a message to itself. On every message received toggle a pin.</td>
</tr>
<tr>
<td vAlign="top" align="right" width="111"><b>Value:</b></td>
<td vAlign="top" width="576">Provides a simple example of PDO implementation.<br />Implements a metric for measuring/estimating system throughput.</td>
</tr>
</table>
<p>Implementing a PDO for VELOOS requires three steps:</p>
<ul>
<li>Declaring a class</li>
<li>Implementing message handler and initializer</li>
<li>Instantiating an object</li>
</ul>
<h3>Declaring a class</h3>
<p>Class declaration sections starts with <i>VOS_Classes</i> macro and ends with beginning of any other section. As with regular MP ASM sections, there is no explicit &#8216;section end&#8217; therefore it is important to properly delimit class declaration sections. A source file may have only one class declaration sections (MP ASM constraints).</p>
<p>Within class declaration section, a class is declared <i>VOS_mClass</i> macro. The macro should be preceded with a class name &#8211; a valid MP ASM label. This macro generates the class&#8217;s dispatch table. It accepts two labels as parameters: message handler and initialization handler. These labels should be known in this module (e.g. defined in the same module or imported with extern directive).</p>
<p><code style="text-align:left"><br />
<b><span style="COLOR: #333399">VOS_Classes</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Class definitions begin</span><br />
MyClass <b><span style="COLOR: #333399">VOS_mClass</span></b> MyHandler,&nbsp;MyInit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">;&nbsp;MyClass implementes MyHandler and MyInit methods</span><br />&nbsp;<br />
&nbsp;&nbsp;&nbsp; code<br />
MyInit<br />
&nbsp;&nbsp;&nbsp; ...<br />
&nbsp;&nbsp;&nbsp; return<br />
&nbsp;<br />
MyHandler<br />
&nbsp;&nbsp;&nbsp; ...<br />
&nbsp;&nbsp;&nbsp; return<br />
</code></p>
<h3>Instantiating an object</h3>
<p>Object instantiation section begins with <i>VOS_Objects</i> macro and ends with beginning of any other section. It accepts two parameters &#8211; class name and object data. Object data can be any 8-bit value. System does not make any assumption on it, it just loads this value to system variable <i>This</i>. Class name must be a label of a previously declared class. It should be known in this module.</p>
<p><code style="text-align:left"><br />
&nbsp;<br />
<b><span style="COLOR: #333399">VOS_Objects</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Object registry begins</span><br />
MyObject<br />&nbsp;<b><span style="COLOR: #333399">VOS_mPersistentObject</span></b> MyClass,&nbsp;0&nbsp;&nbsp;<span style="COLOR: green">;&nbsp;Instance of MyClass constructed with object data == 0</span><br />
&nbsp;<br />
</code></p>
<p>Objects can be instantiated in the same unit where class implemented or in a different unit. In latter case, class name should be exported with <i>global</i>directive.</p>
<h3>Note on Class Reenterability</h3>
<p>A reenterable class allows instantiating several objects. From the system point of view all classes are reenterable. Whether a particular class is reenterable or no depends on its design and implementation and it is up to developer to make such decision. To make a class reenterable, all resources it uses must be allocated by means of object data. PDO implemented in this example is not<br />
reenterable.</p>
<h3>Implementing a message handler</h3>
<p>Message handler is a subroutine, called by the OS when it finds a message addressed to this object or a broadcast message. On handler entrance <i>This</i> is loaded with object data and FSR is pointing to the message ID, so that the handler may compare INDF to a (set of) message ID(s) known to PDO. A PDO should process only know messages and ignore all others. Once the message is recognized, PDO may increment FSR and access message data (if necessary). In this example message has no custom data.</p>
<h3>Implementing an initializer</h3>
<p>Initializer is a subroutine, called by the OS on start-up (power up and reset events). On its entrance <i>This</i> is loaded with object data. Initializer is called for every instantiated object, therefore Initializer should prepare all registers or periphery used by this particular instance. If there is a need of some initialization code executed for all instances PDO should implement a boot handler.</p>
<h3>Sending a message</h3>
<p>VELOOS provides few macros for sending messages. Each of those macro &#8220;allocates&#8221; space for a new message, places acceptor handle, message ID, sender handle (in the last location). When it completes, FSR is pointing to custom data location,<br />
so that PDO may put message data if necessary.</p>
<table id="Table2" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellSpacing="0" cellPadding="0" border="1">
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" align="center" width="154"><b>Macro</b></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" align="center" width="269"><b>Parameters</b></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" align="center" width="294"><b>Description</b></td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="154"><b><code><span style="COLOR: #333399">VOS_mPostMessage</span></code></b></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="269"><code>obj_to</code>&nbsp;- accepter handle<br />
<code>msg_id</code>&nbsp;- message ID</td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="294">Posts a message to a statically defined object. Both message ID and acceptor are defined at build time</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="154"><b><code><span style="COLOR: #333399">VOS_mBroadcastMsg</span></code></b></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="269"><code>msg_id</code>&nbsp;- message ID</td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="294">Posts a broadcast message. Message ID defined at build<br />
time</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="154"><b><code><span style="COLOR: #333399">VOS_mPostMsgIndir</span></code></b></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="269"><code>obj_ptr</code>&nbsp;  file containing accepter handle<br />
<code>msg_id</code>&nbsp;  message ID</td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="294">Posts a message to an object using handle stored in a file, e.g. Acceptor is defined at run time while message ID at build time</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="154"><b><code><span style="COLOR:#333399">VOS_mPostMsgDyn</span></code></b></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="269"><code>obj_ptr</code>&nbsp;  file containing accepter handle<br />
<code>msg_file</code>&nbsp;  file containing message ID</td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="294">Posts a message to an object using handle stored in a file and message ID stored in another file. Both acceptor and message ID are defined at run time</td>
</tr>
</table>
<p>In this example only one form is used:</p>
<p><code style="text-align:left">&nbsp;&nbsp;&nbsp; <b><span style="COLOR: #333399">VOS_mPostMessage</span></b> MyObject,&nbsp;2&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; post message to MyObject</span><br />
&nbsp;<br /></code></p>
<h3>Implementing a boot handler</h3>
<p>Boot handler is a fragment of code executed by the system on start-up. It is not related with any class or object. A boot handler is implemented by placing code to <i>VOS_BootHandlers</i> section. Since an asm file may have only one occurrence of a section name there could be only one boot handler in a source asm file. However, application that consists of many files may have many boot handlers. Order of execution is not known and not fixed, therefore the code should not relay on any particular order. When boot handler is executed objects are not initialized</p>
<p><code style="text-align:left"><br />
&nbsp;<br />
<b><span style="COLOR: #333399">VOS_BootHandlers</span></b> code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; starts a section for the application boot handler</span><br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp; ANSEL<br />
&nbsp;&nbsp;&nbsp; clrf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ANSEL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">;&nbsp;Turn all pints to digital</span><br />
<br />
&nbsp;&nbsp;&nbsp; clrf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ANSELH<br />
&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp;<br />
OSCCON&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Set Fosc = 8Mhz</span><br />
&nbsp;&nbsp;&nbsp; movlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (.7 &lt;&lt; IRCF0)<br />
&nbsp;&nbsp;&nbsp; movwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OSCCON<br />
&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; !!! NO RETURN ALLOWED !!!</span><br />
</code></p>
<h3>Building the project</h3>
<p>A VELOOS project, to be properly built, should include VELOOS kernel (<code>vos.asm</code>) and VELOOS specific instructions in the linker script for the target device. Unfortunately, MP LAB does not support multiple lkr files (it just takes the first one) therefore changes have to be made in a copy of a standard .lkr file distributed with MP LAB.</p>
<p>VELOOS can be configured (fine tuned) at build time. All configurable parameters are given in a separate inc file.</p>
<p>A package with sources for this example can be downloaded on <a href="http://hutorny.in.ua/wp-content/uploads/2006/11/VELOOS-Example1.zip">this link</a>. It includes the following files:</p>
<table id="Table3" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellSpacing="0" cellPadding="0" border="1">
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>Example1.mcp</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: windowtext 1pt solid; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">MP LAP project file</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>main.asm</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">Example1 application sources</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>pic.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">Processor-specific primitives, macros and includes</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>pic16.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">PIC16/PIC12 specific primitives</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vos.asm</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS kernel</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vos.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS public interface</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>vos_cfg.inc</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS configuration file</td>
</tr>
<tr>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: windowtext 1pt solid; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="177"><code>16f690.lkr</code></td>
<td style="BORDER-RIGHT: windowtext 1pt solid; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: windowtext 1pt solid" vAlign="top" width="540">VELOOS specific linker script</td>
</tr>
</table>
<p><a id=p77 href="http://hutorny.in.ua/wp-content/uploads/2006/11/VELOOS-Example1.zip">Download Example1 Sources</a></p>
<table>
<tr>
<td>
<h3>Simulation results</h3>
<p>Figure 1 shows Logic Analyzer trace (20000&nbsp;IC&nbsp;=&nbsp;10 ms). As it can be easily counted, this example processes 13 messages per millisecond with turnaround in about 150 IC. Any load on CPU will decrease this number (which will be illustrated in the next example). 150 IC per message can be considered as messaging overhead and should be accounted when designing time-critical applications.</p>
</td>
<td>&nbsp;</td>
<td><a target=_blank href="http://hutorny.in.ua/wp-content/uploads/2006/11/SIM-RA1-Trace.png" rel="thumbnail"><img id="image76" height=60 alt="Example1. Logic Analyzer Trace" src="http://hutorny.in.ua/wp-content/uploads/2006/11/SIM-RA1-Trace.thumbnail.png" /></a><br /><span align="center">Figure 1</span></td>
</tr>
</table>
<h3>Application Source</h3>
<p><code style="text-align:left"><br />
  &nbsp;<br /><span style="COLOR: green">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; License:&nbsp;&nbsp; Licensed to public under the Open Software License</span><br /><span style="COLOR: green">;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.opensource.org/licenses/osl-3.0.php"><span style="COLOR: green; TEXT-DECORATION: none; text-underline: none">http://www.opensource.org/licenses/osl-3.0.php</span></a><br />&nbsp;include "pic.inc"<br />&nbsp;include "vos.inc"<br />&nbsp;<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />&nbsp;__CONFIG&nbsp;_WDT_ON&nbsp;&amp;&nbsp;_INTRC_OSC_NOCLKOUT&nbsp;&amp;&nbsp;_CP_OFF&nbsp;&amp;&nbsp;_PWRTE_ON &amp;&nbsp;_MCLRE_ON&nbsp;&amp;&nbsp;_FCMEN_OFF&nbsp;&amp;&nbsp;_BOR_OFF&nbsp;&amp;&nbsp;_IESO_OFF<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
&nbsp;<br />
&nbsp;constant mask = .2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; mask to be used for driving port (RA1)</span><br />
&nbsp;constant msgid = 040h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; message ID</span><br />
  <br />
  &nbsp;<br />
  <b><span style="COLOR:#333399">VOS_Classes</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Class definitions begin</span><br />
  MyClass <b><span style="COLOR: #333399">VOS_mClass</span></b> MyHandler,&nbsp;MyInit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; MyClass implementes MyHandler and MyInit methods</span><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Class definitions end with beginning of the next code section</span><br />
  <b><span style="COLOR:#333399">VOS_Objects</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Object registry begins</span><br />
MyObject<br />
&nbsp; <b><span style="COLOR:#333399">VOS_mPersistentObject</span></b>&nbsp;MyClass,&nbsp;mask&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<span style="COLOR: green">; Instance of MyClass constructed with object data == mask</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Object registry ends with beginning of the code next section</span><br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />
  <br />&nbsp;&nbsp;&nbsp; code<br />
MyInit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; This was loaded with object data</span><br />
&nbsp;&nbsp;&nbsp; comf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="COLOR:#333399">This</span></b>,&nbsp;W&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; W := ~mask</span><br />
  <br />&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp; TRISA<br />&nbsp;&nbsp;&nbsp; movwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TRISA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Prepare port for output</span><br />&nbsp;&nbsp;&nbsp; <b><span style="COLOR:#333399">VOS_mPostMessage</span></b>&nbsp;MyObject,&nbsp;msgid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; post message to itself</span><br />
&nbsp;&nbsp;&nbsp; return<br />
<span style="COLOR: green">;------------------------------------------------------------------------------</span><br />&nbsp;<br />
MyHandler&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; FSR points to message ID field, This is loaded with object data</span><br />&nbsp;&nbsp;&nbsp; movlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msgid<br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; INDF,&nbsp;W&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; if message.msg_id &lt;&gt; msgid</span><br />
&nbsp;&nbsp;&nbsp; skpz<br />
&nbsp;&nbsp;&nbsp; return&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; return</span><br />
&nbsp;&nbsp;&nbsp; movf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span style="COLOR: #333399">This</span></b>,&nbsp;W<br />&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp; PORTA<br />
&nbsp;&nbsp;&nbsp; xorwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PORTA,&nbsp;F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Toggle port</span><br />
&nbsp;&nbsp;&nbsp; <b><span style="COLOR: #333399">VOS_mPostMessage</span></b>MyObject,&nbsp;msgid&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; <span style="COLOR: green">; post message to itself</span><br />
&nbsp;&nbsp;&nbsp; return<br /><span style="COLOR: green">;------------------------------------------------------------------------------</span><br />&nbsp;<br />
<b><span style="COLOR: #333399">VOS_BootHandlers</span></b> code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; starts a section for the application boot handler</span><br />&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp; ANSEL<br />&nbsp;&nbsp;&nbsp; clrf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ANSEL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;<span style="COLOR: green">; Turn all pints to digital</span><br />&nbsp;&nbsp;&nbsp; clrf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ANSELH<br />&nbsp;&nbsp;&nbsp; banksel&nbsp;&nbsp;&nbsp;&nbsp;OSCCON&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: green">; Set Fosc = 8Mhz</span><br />&nbsp;&nbsp;&nbsp; movlw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (.7 &lt;&lt; IRCF0)<br />&nbsp;&nbsp;&nbsp; movwf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OSCCON<br />&nbsp;&nbsp;&nbsp; <span style="COLOR: green">; !!! NO RETURN ALLOWED !!!</span><br /><span style="COLOR: green">;------------------------------------------------------------------------------</span><br />&nbsp;<br />&nbsp;end<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/pic/veloos/veloos-example-1/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Very Low Overhead Operating System</title>
		<link>http://hutorny.in.ua/projects/pic/very-low-overhead-operating-system</link>
		<comments>http://hutorny.in.ua/projects/pic/very-low-overhead-operating-system#comments</comments>
		<pubDate>Mon, 30 Oct 2006 00:47:14 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[PIC]]></category>
		<category><![CDATA[VELOOS]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/uncategorized/very-low-overhead-operating-system</guid>
		<description><![CDATA[VELOOS&#160;-&#160;Very&#160;Low&#160;Overhead&#160;Operating&#160;System VELOOS is a message-triggered cooperative operating system designed to run in places were a large vehicles can not run. Its implementation for PIC12F takes less than 200 instructions and 20 data registers1. With addition of a timer driver, it becomes a time-triggered RTOS. Preface What is a real-time operating system in context of an [...]]]></description>
			<content:encoded><![CDATA[<p>VELOOS&nbsp;-&nbsp;<b>Ve</b>ry&nbsp;<b>L</b>ow&nbsp;<b>O</b>verhead&nbsp;<b>O</b>perating&nbsp;<b>S</b>ystem</p>
<p>VELOOS is a message-triggered cooperative operating system designed to run in places were a large vehicles can not run. Its implementation for PIC12F takes less than 200 instructions and 20 data registers<a title="" href="#_ftn1" name=_ftnref1><sup><span style="FONT-SIZE: smaller">1</span></sup></a>. With addition of a timer driver, it becomes a time-triggered RTOS.</p>
<p><span id="more-74"></span></p>
<link rel="stylesheet" type="text/css" href="http://hutorny.in.ua/common/std.css" media="all"/>
<h2>Preface</h2>
<p>What is a real-time operating system in context of an MCU? First, it is an abstraction intended to share MCU resources among application components. Whatever abstraction is used in RTOS, it drives the application design &#8211; e.g. if a RTOS operates in terms of tasks, an application developer is obeyed to program application as a set of tasks. <br />
Secondly &#8211; it is a set of services which an application developer may/should use to make application operable and achieve the application goals. Most common abstraction for RTOS is a multitasking. Multitasking has several advantages, which make it very appealing, however it also has disadvantages which are even more noticeable in context of an MCU applications.</p>
<h3>Disadvantages of multitasking</h3>
<p>1. It is costly (high resource consuming)</p>
<p>Task switching requires saving and restoring task context, which includes stack, some system registers and some hardware SFR&#8217;s (such as status).</p>
<p>2. Inter-task communications even more costly</p>
<p>Tasks abstractions were designed for executing rather isolated and limited in time routines. Task communication and synchronization requires use of other abstractions, such as semaphores, pipes, etc. These<br />
communications/synchronizations features are usually accessible as functions and they are not trivial in implementation and use.</p>
<p>3. It is not well suitable for event driven applications</p>
<p>Many of MCU applications are event-driven &#8211; a particular application routine is executed on e response of an external event. When implementing such application with a multitasking, developer should map application requirements to available abstractions &#8211; e.g. decompose the application onto tasks. For an event-driven application this mapping is not trivial and creates unnecessary complications.</p>
<p>4. It is redundant</p>
<p>Multitasking assumes decomposing application on isolated or loosely coupled set of tasks which, due to nature of MCU applications, are implemented as infinite loops &#8211; every task implements an infinite loop. Memory allocated to a task usually is not used in other tasks, even if the task is in idle mode.</p>
<h2>Alternate RTOS abstraction</h2>
<p>Messaging is an alternate abstraction, which fits better for event-driven applications. With this abstraction an application is decomposed to set of process data objects (PDO) which receive and send messages in a response to other messages or external events, such as port change, periphery interrupts or timer.</p>
<p>Messaging provides a simple mechanism for both sharing CPU time and communicating among PDO&#8217;s. Despite messaging is also not a perfect abstraction, it requires fewer resources and needs implementation of very few and very simple abstractions &#8211; message, message queue, send message, and message handlers. All other abstractions and mechanism can be built with (on top of) these four and this is how VELOOS is designed and implemented.</p>
<h2>VELOOS description</h2>
<p>VELOOS design is based on few rather simple design decisions for establishing message processing. </p>
<h3>Terminology</h3>
<p>(It also reflects major design decisions)</p>
<table id=Table1 style="BORDER-COLLAPSE: collapse;" cellSpacing=0 cellPadding=0 border=0>
<tr>
<td vAlign=top width=140>
      <b><u>Message</u></b></td>
<td vAlign=top width=451>
A fixed-size set of sequential general-purpose registers. Message embeds accepter address, message ID and applications data. By default, message is 4 bytes long with 2 bytes available for custom data.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Message Queue</u></b></td>
<td vAlign=top width=451>
A circular buffer of fixed configurable size.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Send Message,<br />Post Message</u></b></td>
<td vAlign=top width=451>
A routine that accepts object handle and message ID, places them into the message area and returns indirect access register pointing to custom data locations. Messages are sent in asynchronous mode &#8211; sender does not wait until accepter processes the message.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Message Handler</u></b></td>
<td vAlign=top width=451>
A routine provided by application developer for processing messages. This routine is invoked by the system when it encounters a message addressed to the object.</td>
</tr>
<tr>
<td vAlign=top width=140>
      &nbsp;</td>
<td vAlign=top width=451>&nbsp;</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Addressing Modes</u></b></td>
<td vAlign=top width=451>
Messages can be addressed to a specific object (direct addressing) or to all registered objects (broadcast addressing). The latter one is indicated by use of a reserved object address &#8211; FF</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Broadcast Message</u></b></td>
<td vAlign=top width=451>
Message sent to all instantiated objects</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Object Address,<br />Handle</u></b></td>
<td vAlign=top width=451>
An 8-bit value uniquely identifying an object. In VELOOS, handle is a synonym of Object Address. VELOOS makes up handle values from lower octet of object entry address.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Object Entry</u></b></td>
<td vAlign=top width=451>
Pair {class&nbsp;pointer,&nbsp;object&nbsp;data} placed in the object registration section.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Object Instantiation</u></b></td>
<td vAlign=top width=451>
Predefined and required way of registering objects in the OS. It creates registration entry in the system and provides value for the object handle. Currently VELOOS implements only build-time object instantiation.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Object Initializer</u></b></td>
<td vAlign=top width=451>
An application routine provided by the application developer for initialization of registers and periphery used by a particular PDO instance. It is called on system startup.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Object Data</u></b></td>
<td vAlign=top width=451>
Any 8-bit value provided by the application developer and suitable for distinguishing among object instances. The system makes no assumption on object data value, it just loads it to system variable <b>This</b>.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Class</u></b></td>
<td vAlign=top width=451>
Set of entries/routines required for instantiating and operating an object &#8211; e.g. handler and initializer.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Class Entry</u></b></td>
<td vAlign=top width=451>
Pair of jumpers {goto&nbsp;handler,&nbsp;goto&nbsp;initializer} used for dispatching the system calls to an object</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Class Pointer</u></b></td>
<td vAlign=top width=451>
Lower octet of class entry address</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Class Definition</u></b></td>
<td vAlign=top width=451>
Predefined and required way of registering classes in the OS. It creates class entry in the system and provides value for the class pointer</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>VELOOS driver</u></b></td>
<td vAlign=top width=451>
Software that provides access to a shared resource and/or handles interrupts. A driver may consist of an object and an interrupt handler (IH)- a fragment of interrupt service routine.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Boot Handler</u></b></td>
<td vAlign=top width=451>
Fragment of application startup routine, provided by a PDO or driver for initializing of resources not associated with a particular PDO.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Interrupt Handler</u></b></td>
<td vAlign=top width=451>
Fragment of ISR provided by the application or a driver for handling concrete interrupt. Custom ISR are ordered and linked accordingly to (logical) priority assigned to it. VELOOS provides the prolog and epilog handlers, which provide context saving and restoring.</td>
</tr>
</table>
</p>
<h3>Principle of Operations</h3>
</p>
<table style="BORDER-COLLAPSE: collapse;" cellSpacing=0 cellPadding=0 border=0 ID="Table2">
<tr>
<td vAlign=top width=140>
      <b><u>System Startup</u></b></td>
<td vAlign=top width=451>
On reset, system executes internal startup routines, and application boot handler. Then system enumerates trough object registry and for each entry calls object initializer.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Interrupt Handling</u></b></td>
<td vAlign=top width=451>
On an interrupt, the prolog handler saves all critical SFRs in temporary registers. Then control is transferred to a next interrupt handler. IH check the interrupt source and if the source is proper, handles the interrupt. As a result of handling an interrupt, IH may post a message. If the source improper, IH skips its body. After all IH were executed, control is transferred to the epilog handler, which restores the context and exits the interrupt.</td>
</tr>
<tr>
<td vAlign=top width=140>&nbsp;</td>
<td vAlign=top width=451>&nbsp;</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Operating Mode</u></b></td>
<td vAlign=top width=451>
VELOOS points to the next message in the queue, retrieves accepter address from the message. If it is a broadcast message, system enters broadcast state. Otherwise, it enters Call Handler State.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Call Handler State</u></b></td>
<td vAlign=top width=451>
System loads the accepter&#8217;s class pointer to system variable <b>This_class</b> and object data to system variable <b>This</b> and calls the message handler. The message handler is expected to complete execution in a predefined timeframe. If it does not, system enters into timeout state. During processing a message, PDO may post message(s) to other objects, including message(s) to itself and broadcast messages. When the message queue is empty, system enters Idle state.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Broadcast State</u></b></td>
<td vAlign=top width=451>
VELOOS enumerates trough object registry and for each entry it calls corresponding handler.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Idle State (optional)</u></b></td>
<td vAlign=top width=451>
VELOOS maintains posts Idle message and calls handler for the next object. If the message queue is not empty after this call, system leaves idle state. VELOOS maintains a dedicated &#8216;next idle object&#8217; pointer, which is incremented after each handler is call for the idle message. This ensures that every PDO gets idle message.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Timeout State</u></b></td>
<td vAlign=top width=451>
If a PDO fails to handle message in the given timeframe, VELOOS will abort handler routine and proceed with the next message in the queue. VELOOS provides two optional mechanisms for controlling execution time &#8211; the hardware watchdog timer (WDT) and software WDT based on a timer driver. Both mechanisms may work simultaneously.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Message Queue Overflow</u></b></td>
<td vAlign=top width=451>
When the message queue is overflowed, system sets Queue Overflow flag and overwrites an existing message &#8211; the first in the queue.</td>
</tr>
<tr>
<td vAlign=top width=140>&nbsp;</td>
<td vAlign=top width=451>&nbsp;</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Time Triggering</u></b></td>
<td vAlign=top width=451>
Time triggering is implemented with a heartbeat broadcast message sent by a timer driver with fixed periodicity (1 ms by default). VELOOS timer drivers also have option for additional 1 sec heartbeat.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Time Intervals</u></b></td>
<td vAlign=top width=451>
VELOOS does not provide an explicit mechanism for controlling time intervals between object activations. PDOs are expected to watch for proper time interval via heartbeat, using either time value provided with the heartbeat message or using countdown approach.</td>
</tr>
<tr>
<td vAlign=top width=140>&nbsp;</td>
<td vAlign=top width=451>&nbsp;</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>VELOOS drivers</u></b></td>
<td vAlign=top width=451>
Currently VELOOS provides two drivers: TMR0 based timer driver and TMR2/CCP based timer driver.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Persistent Storage</u></b></td>
<td vAlign=top width=451>
VELOOS provides two options for storing object registry &#8211; ROM and EEPROM. Class registry is stored in ROM.</td>
</tr>
<tr>
<td vAlign=top width=140>
      <b><u>Call Back</u></b></td>
<td vAlign=top width=451>
Callback is a message sent back from the accepter to the sender. System places sender&#8217;s handle as the last byte in the message and if the PDO does not override it, the accepter may use this handle to send a message back.</td>
</tr>
</table>
</p>
<h2>VELOOS implementation</h2>
</p>
<p>VELOOS is designed and implemented in MP ASM language. Its primitives are implemented as ASM routines or macro.</p>
<h3>VELOOS requirements</h3>
</p>
<table style="BORDER-COLLAPSE: collapse;" cellSpacing=0 cellPadding=0 width=593 border=1 ID="Table3">
<tr>
<td vAlign=top width=253>
      <span style= "TEXT-ALIGN: right">PIC family</span><br />
      <span style= "TEXT-ALIGN: left">Feature</span></td>
<td vAlign=top width=113 align=center>
      <b><span style= "FONT-SIZE: larger">PIC12F675</span></b><br />
      program/data</td>
<td vAlign=top width=113 align=center>
      <b><span style="FONT-SIZE: larger">PIC16F690</span></b><br />
      program/data</td>
<td vAlign=top width=113>
<p style="TEXT-ALIGN: center" align=center><b><span style="FONT-SIZE: larger">PIC18F</span></b><br />
      program/data</p>
</td>
</tr>
<tr>
<td vAlign=top width=253>Bare operating system</td>
<td vAlign=top width=113 align=center>195/20</td>
<td vAlign=top width=113 align=center>220/20</td>
<td vAlign=top width=113 align=center>210/20</td>
</tr>
<tr>
<td vAlign=top width=253>Heartbeat Timer (1ms, 1s)</td>
<td vAlign=top width=113 align=center>75/7</td>
<td vAlign=top width=113 align=center>85/7</td>
<td vAlign=top width=113 align=center>70/7</td>
</tr>
<tr>
<td vAlign=top width=253>A definition of class (per class)</td>
<td vAlign=top width=113 align=center>2/0</td>
<td vAlign=top width=113 align=center>2/0</td>
<td vAlign=top width=113 align=center>2/0</td>
</tr>
<tr>
<td vAlign=top width=253>An object instance (per object)</td>
<td vAlign=top width=113 align=center>2/0</td>
<td vAlign=top width=113 align=center>2/0</td>
<td vAlign=top width=113 align=center>2/0</td>
</tr>
</table>
<p>&nbsp;</p>
<h2>Possible extensions</h2>
</p>
<h3>Simple Networking with VELOOS</h3>
<p>Messaging approach used by VELOOS allows implementing simple distributed computing in a simple and transparent way. First of all networking would need a network driver (a VELOOS class) that implements physical communication between MCU&#8217;s. This driver should be able to (1) filer incoming messages, (2) pack and send filtered messages via communication channel, (3) unpack messages coming from the communication channel and (4) post them to local message queue. Then, for every remote object application should instantiate a local proxy object (as an instance of network driver class). With this approach, an application can be easily distributed among several execution nodes (MCUs).</p>
<h3>Various object lifetime</h3>
<p>Currently the system implements only one lifetime scope for PDO. It is possible to extend this implementation for static objects (stored in ROM), persistent objects (stored in EEPROM), and dynamic objects (created in run-time and stored in RAM). </p>
<h3>Exception handling</h3>
<p>Currently the system has two exceptional situations (Handler&nbsp;Timed&nbsp;Out and Message&nbsp;Queue&nbsp;Overflowed) and provides no ability for changing behavior on these exceptions. VELOOS can be extended with exception handler support, by, for example, providing third jumper to the class entries, which would be called by the system when an exception occurs.</p>
<h3>Class and Object Directory</h3>
<p>Currently the system does not provide a mechanism for retrieving a list of classes and objects registered in the system. This feature can be implemented by class entry with additional jumper, which would return<br />
class/object identification data in for, for example, human-readable class/object names.</p>
<h2>Related Posts</h2>
<p><a href="http://hutorny.in.ua/projects/pic/veloos/veloos-example-1">VELOOS Example1 &#8211; Self-triggering PDO</a></p>
<p><a href="http://hutorny.in.ua/projects/pic/veloos/veloos-example-2">VELOOS Example2 &#8211; Heartbeat Driven PDO</a></p>
<p><a href="http://hutorny.in.ua/projects/pic/veloos/veloos-example-3">VELOOS Example3 &#8211; USART Controlled actuators and Generators</a></p>
<p><a href="http://hutorny.in.ua/projects/pic/miha675-multi-input-hall-automaton">MIHA675 &#8211; a sample VELOOS application</a></p>
<p><a href="http://hutorny.in.ua/veloos/">All VELOOS related</a></p>
<p><a href="http://hutorny.in.ua/wp-content/uploads/2006/11/veloos_v1_0.zip">Download VELOOS v.1.0</a></p>
<h2>Future Posts</h2>
<p>VELOOS sample application (planned)</p>
<p>VELOOS reference (planned)</p>
<div style="mso-element: footnote-list"><br clear=all/></p>
<hr align=left width="33%" SIZE=1/>
<div id=ftn1 style="mso-element: footnote">
<p class=MsoFootnoteText><a title="" style="mso-footnote-id: ftn1" href="#_ftnref1" name=_ftn1><sup><span style="FONT-SIZE: smaller">[1]</span></sup></a> Minimal configuration with broadcasting and message queue for 2 messages</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/pic/very-low-overhead-operating-system/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Random theses</title>
		<link>http://hutorny.in.ua/projects/e/random-theses</link>
		<comments>http://hutorny.in.ua/projects/e/random-theses#comments</comments>
		<pubDate>Fri, 15 Sep 2006 22:09:28 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[e#]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/e/random-theses</guid>
		<description><![CDATA[This post collects and organizes discussion theses posted on different forums. MCU Models Despite it is not explicitly spelled out, assemblers and C-compilers do use one or the other kind of MCU model, defined in terms of the programming language (assembly, C or preprocessor). These models are &#8216;flat&#8217; (set of constants or static variables). These [...]]]></description>
			<content:encoded><![CDATA[<p>This post collects and organizes discussion theses posted on different forums.<br />
<span id="more-73"></span></p>
<h3>MCU Models</h3>
<p>Despite it is not explicitly spelled out, assemblers and C-compilers do use one or the other kind of MCU model, defined in terms of the programming language (assembly, C or preprocessor). These models are &#8216;flat&#8217; (set of constants or static variables). These models are often incomplete and can be easily misused without any compilation error.<br />
Linkers and simulators use another way of defining the same model and doing it in other, different languages with no or very little documentation support.<br />
e# will give ability to define a formal, self-descriptive MCU model once and open it for use everywhere ??“ in compiler, application, and simulator. This indeed does not negate the need to learn the hardware. Instead e# will provide a formalized addendum to the device datasheet.<br />
Defining MCU model in the same language as the program is written will open up possibilities hardly achievable in the current tools.</p>
<h3>Cost of abstractions</h3>
<p>All proposed abstractions are abstractions of the tool language. They will be constructed and executed on the host computer. There will be no abstraction one would have to use on the device. One still will be able to program in terms of instructions, and on top of that, may define abstractions for the device in extents of available device resources. For example, one would be able to define (and implement) an interface method call using whatever calling convention is appropriate and use it as if it were a HLL language.</p>
<h3>Generic MCU</h3>
<p>Many parts in an embedded application (such as state machine, math, conversion, etc.) can be written for a &#8216;more generic MCU&#8217; and these parts can be transferred to other MCU that fit under the same &#8216;generality umbrella&#8217;. This will give developers freedom to make such choice &#8211; either writing with very limited very generic MCU and have highly portable code or writing for a given MCU and have more efficient and, of course, less portable code.</p>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/e/random-theses/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>e# language vision as an &#8216;embryonic development&#8217; story</title>
		<link>http://hutorny.in.ua/projects/e/e-language-vision-as-an-embryonic-development-story</link>
		<comments>http://hutorny.in.ua/projects/e/e-language-vision-as-an-embryonic-development-story#comments</comments>
		<pubDate>Sat, 09 Sep 2006 12:41:16 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[e#]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/e/e-language-vision-as-an-embryonic-development-story</guid>
		<description><![CDATA[In this post I present my vision of e# reflected through history of assemblers. For each stage in the assemblers&#8217; history I am providing presumptive equivalents in e#, incrementing the complexity of each next example. Statements, reused from the previous step are grayed out to focus you attention on new features. Bold indicates possible keywords [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I present my vision of e# reflected through history of assemblers. For each stage in the assemblers&#8217; history I am providing presumptive equivalents in e#, incrementing the complexity of each next example.<br />
<span id="more-72"></span><br />
Statements, reused from the previous step are grayed out to focus you attention on new features. Bold indicates possible keywords of e#-tool language.</p>
<p>I hope this way of expressing will help the reader to understand my idea and an approach on its implementation.</p>
<p>&nbsp;</p>
<table border="1" cellspacing="0" cellpadding="0" width="674" style="border-collapse:collapse;">
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" style="padding:0cm 5pt 0cm 5pt;">
<p><em><u>&#8216;Ancient&#8217; programming</u></em><br />
        <span style="text-align:justify;">Instruction codes are directly placed to the current location of the executable image as binary values.</span></p>
</td>
<td width="403" valign="bottom" style="padding:0cm 0pt 0cm 0pt;"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>B'00 0000 0000 0000'</td>
</tr>
<tr>
<td>B'00 0000 0000 0000'</td>
</tr>
<tr>
<td>B'10 1000 0000 0000'</td>
</tr>
</table>
<p></code></td>
</tr>
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" border="1" style="padding:0cm 5pt 0cm 5pt;">
<p><em><u>Mnemonic assembler</u></em><br />
        <span style="text-align:justify;">Instead of writing in binary codes, commands are replaced with their mnemonic names. Mnemonics are defined with keyword <strong>instruction</strong> and implemented as a placement of proper instructions codes</span></p>
</td>
<td width="403" valign="bottom" style="padding:0cm 0pt 0cm 0pt;"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td><strong>instruction</strong> nop {<strong> </strong>(B'00 0000 0000 0000'); };</td>
</tr>
<tr>
<td><strong>instruction</strong> goto(<strong>bit11</strong> addr)</td>
</tr>
<tr>
<td>{(B'10 1000 0000 0000' | ( addr &amp; B'111 1111 1111')); };</td>
</tr>
<tr>
<td>nop;</td>
</tr>
<tr>
<td>nop;</td>
</tr>
<tr>
<td>goto 0;</td>
</tr>
</table>
<p></code></td>
</tr>
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" style="padding:0cm 5pt 0cm 5pt;">
<p><em><u>Symbolic assembler</u></em><br />
        <span style="text-align:justify;">On this stage addresses are replaced with symbolic names and instructions operate on names rather then on addresses. A new essence is introduced &ndash; <strong>label</strong>. Instruction goto renamed to go due to change in notation and it is defined for the label only, thus developer can not apply it for a data address.</span></p>
</td>
<td width="403" valign="bottom" style="padding:0cm 0pt 0cm 0pt;"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td style="background:#F3F3F3;"><strong><span style="color:gray; ">instruction</span></strong><span style="color:gray; "> nop {<strong> </strong>(B'00 0000 0000 0000'); }</span></td>
</tr>
<tr>
<td><strong>instruction</strong> label.go</td>
</tr>
<tr>
<td>{(B'10 1000 0000 0000' | (<strong>this</strong> &amp; B'111 1111 1111' )); };</td>
</tr>
<tr>
<td><strong>&nbsp;</strong></td>
</tr>
<tr>
<td>label there;</td>
</tr>
<tr>
<td>nop; nop;</td>
</tr>
<tr>
<td>there.go;</td>
</tr>
</table>
<p></code></td>
</tr>
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" style="padding:0cm 5pt 0cm 5pt;">
<p><em><u>Relocatable assembler</u></em><br />
        <span style="text-align:justify;">This approach has introduced sections &ndash; logical portions of code with unspecified absolute addresses<a href="#_ftn1" name="_ftnref1" title="see footnote 1" id="_ftnref1"><sup>1</sup></a>. A new essence is introduced &ndash; section. Section is started by specifying its class (type) and optionally name. Section scope is denoted by braces. Named sections are accessible as build-time objects, some of their properties (such as size, absolute addresses) can be made available as run-time constants.</span></p>
</td>
<td width="403" valign="bottom" style="padding:0cm 0pt 0cm 0pt;"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>instruction</strong> nop { (B'00 0000 0000 0000'); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>instruction</strong> label.go</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;{ (B'10 1000 0000 0000' | (<strong>this</strong> &amp; B'00 0111 1111 1111' )); };</span></td>
</tr>
<tr>
<td><strong>instruction</strong> file.inc</td>
</tr>
<tr>
<td>{ (B'00 1010 1000 0000' | (<strong>this</strong> &amp; B'00 0111 1111' )); };</td>
</tr>
<tr>
<td><strong>data </strong>&nbsp;mydata  { file myvar; };</td>
</tr>
<tr>
<td><strong>code </strong>{</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;label there;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;nop; nop;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp; there.go;</span></td>
</tr>
<tr>
<td>&nbsp; myvar.inc; };</td>
</tr>
</table>
<p></code></td>
</tr>
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" style="width:203.4pt;padding:0cm 5pt 0cm 5pt;">
<p><em><u>Infix  assembler</u></em><br />
        <span style="text-align:justify;">Assemblers of this kind have drifted from operation mnemonics and fixed-column format toward to more &#8216;natural&#8217; syntax, especially for assignment and arithmetic operations. This example illustrates alternative definition of instruction <strong>inc</strong><a href="#_ftn2" name="_ftnref2" title="see footnote 2" id="_ftnref2"><sup>2</sup></a>.</span></p>
</td>
<td width="403" valign="bottom"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>instruction</strong> nop {(B'00 0000 0000 0000'); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>instruction</strong> label.go </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">{(B'10 1000 0000 0000' | (<strong>this</strong> &amp; B'00 0111 1111 1111' )); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>instruction</strong> file.inc </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">{(B'00 1010 1000 0000' | (<strong>this</strong> &amp; B'00 0000 0111 1111' )); };</span></td>
</tr>
<tr>
<td><strong>instruction</strong> file '+=' (<strong>const</strong> 1) {<strong> this.</strong>inc; }</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>data </strong>&nbsp;{ file myvar; };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>code </strong>{</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>label</strong> there;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">nop; nop;</span></td>
</tr>
<tr>
<td>myvar += 1;</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">there.go; };</span></td>
</tr>
</table>
<p></code></td>
</tr>
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" style="padding:0cm 5pt 0cm 5pt;">
<p><em><u>Meta-assembler</u></em><br /><span style="text-align:justify;">Meta-assemblers  were aimed making the language device independent by providing a separate,  replaceable device and instruction set definitions. New concepts are introduced  &ndash; device definition and application&#8217;s target device.</span></p>
</td>
<td width="403" valign="bottom"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td><strong>device </strong>PIC16F84;</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>&nbsp; instruction</strong> nop {(B'00 0000 0000  0000'); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>&nbsp; instruction</strong> label.go </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">&nbsp; {(B'10 1000 0000 0000' | (<strong>this</strong> &amp; B'00 0111 1111 1111' )); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>&nbsp; instruction</strong> file.inc</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">&nbsp; {(B'00 1010 1000 0000' | (<strong>this</strong> &amp; B'00 0000 0111 1111' )); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>&nbsp; instruction</strong> file '+=' (<strong>const</strong> 1)</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">&nbsp; {<strong> this</strong>.inc; }</span></td>
</tr>
<tr>
<td><strong>end device;</strong></td>
</tr>
<tr>
<td><strong>application </strong>myapp <strong>for</strong> PIC16F84;</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>&nbsp; data </strong>&nbsp;{ file myvar; };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>&nbsp; code </strong>{</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;"><strong>&nbsp; &nbsp;&nbsp;label</strong> there;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">nop; nop;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">&nbsp;&nbsp;&nbsp;myvar <strong>+=</strong> 1; </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">&nbsp;&nbsp;&nbsp;there.go;  };</span></td>
</tr>
<tr>
<td><strong>end application;</strong></td>
</tr>
</table>
<p></code></td>
</tr>
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" style="padding:0cm 5pt 0cm 5pt;">
<p><em><u>Object-oriented  meta-assembler</u></em><a href="#_ftn3" name="_ftnref3" title="see footnote 3" id="_ftnref3"><sup>3</sup></a><br />
        <span style="text-align:justify;">This stage  contributes object-oriented approach to the device definition and application  programming. Each device resource is defined as an object of a class, these  classes forms a hierarchy and encapsulate implementation details.</span></p>
<p>Application defines and uses build-time  abstractions. Mapping of these abstractions to MCU resources is explicitly  provided by the developer.</p>
</td>
<td width="403" valign="bottom" style="padding:0cm 0pt 0cm 0pt;"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td><strong>device</strong> PIC16F84 <strong>extends</strong> PIC16;</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;<strong>instruction</strong> nop {(B'00 0000 0000  0000'); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong>&nbsp; class</strong> label</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp; <strong>instruction</strong> go </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp; {(B'10 1000 0000 0000' | (<strong>this</strong> &amp; B'00 0111 1111 1111' )); };</span></td>
</tr>
<tr>
<td><strong>&nbsp; end class;</strong></td>
</tr>
<tr>
<td><strong>&nbsp; class</strong> subroutine <strong>extends</strong> label</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;&nbsp; <strong>instruction</strong> call</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  {(B'10 0000 0000 0000' | (<strong>this</strong> &amp; B'00 0111 1111  1111' )); };</span></p>
<tr>
<td><strong>&nbsp; end class;</strong></td>
</tr>
<tr>
<td><strong>&nbsp; class</strong> file</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp; <strong>constructor</strong> { <strong>reserve</strong>(1); }</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  instruction</span></strong><span style="color:gray; "> inc</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  {(B'00 1010 1000 0000' | (<strong>this</strong> &amp; B'00 0000 0111  1111' )); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  instruction</span></strong><span style="color:gray; "> '+=' (<strong>const</strong> 1)</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  {<strong> this.inc</strong>; }</span></td>
</tr>
<tr>
<td><strong>&nbsp; end class;</strong><span style="color:gray; "> </span></td>
</tr>
<tr>
<td><strong>end device; </strong></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong><span style="color:gray; ">application </span></strong><span style="color:gray; ">myapp <strong>for</strong> PIC16F84;</span></td>
</tr>
<tr>
<td>&nbsp; <strong>class</strong> mycount <strong>extends</strong> <strong>private</strong> file</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp; <strong>public</strong> <strong>instruction</strong> inc;</td>
</tr>
<tr>
<td><strong>&nbsp; end class;</strong><span style="color:gray; "> </span></td>
</tr>
<tr>
<td><strong>&nbsp; data </strong>&nbsp;{ mycount myvar;  };</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong><span style="color:gray; ">&nbsp; code </span></strong><span style="color:gray; ">{</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong><span style="color:gray; ">&nbsp; &nbsp;&nbsp;label</span></strong><span style="color:gray; "> there;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong><span style="color:gray; ">&nbsp; &nbsp;&nbsp;nop</span></strong><span style="color:gray; ">; <strong>nop</strong>;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp; &nbsp;&nbsp;myvar <strong>+=</strong> 1; </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; background:#F3F3F3; ">&nbsp; &nbsp;&nbsp;there.<strong>go</strong>;  }</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><strong><span style="color:gray; ">end application;</span></strong><span style="color:gray; "> </span></td>
</tr>
</td>
</tr>
</table>
<p></code></td>
</tr>
<tr style="page-break-inside:avoid;">
<td width="271" valign="top" style="padding:0cm 5pt 0cm 5pt;">
<p><u><span style="e3">e#</span></u><br />
        <span style="text-align:justify;">Proposed  language will support capabilities of all mentioned assemblers and in  addition will provide ability to program builder behavior for all kinds of  activities: resource allocation, image verification, simulation, programming  (the device), documenting and others. This example illustrates statements for  simulation-time verification and documentation<a href="#_ftn4" name="_ftnref4" title="see footnote 4" id="_ftnref3"><sup>4</sup></a>. Device definition provides  code for validating currently selected bank (page) against the bank (page)  intended for access and raises a error if a mismatch is detected. This  technique will help to detect banking errors on early stage. Application uses  simulation-time code to validate initial state of a variable.</span></p>
</td>
<td width="403" valign="bottom" style="padding:0cm 0pt 0cm 0pt;"><code><br />
<table border=0 width="100%" style="border-collapse:collapse;">
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>device</strong>PIC16F84<strong> extends</strong> PIC16;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;  <strong>instruction</strong> nop {(B'00 0000 0000 0000'); };</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;  <strong>class</strong> label</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;  <strong>instruction</strong> go </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp; {(B'10 1000 0000 0000' | (<strong>this</strong> &amp; B'00 0111 1111 1111' )); }</span></td>
</tr>
<tr>
<td><strong>&nbsp;&nbsp;sim </strong>{ <strong>if</strong> !  pageCheck(<strong>this</strong>) <strong>then</strong> <strong>raise</strong> error('&quot;go&quot; paging error);  }</td>
</tr>
<tr>
<td>&nbsp; <strong>doc</strong> { 'GO is  an unconditional branch. The eleven bit immediate value is loaded into PC  bits &lt;10:0&gt;. The upper bits of PC are loaded from PCLATH&lt;4:3&gt;. GOTO  is a two cycle instruction.'};</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;  <strong>end class;</strong></span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;  <strong>class</strong> subroutine <strong>extends</strong> label</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp; <strong>instruction</strong> call</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  {(B'10 0000 0000 0000' | (<strong>this</strong> &amp; B'00 0111 1111  1111' )); }</span></td>
</tr>
<tr>
<td><strong>&nbsp;&nbsp;sim </strong>{ <strong>if</strong> !  pageCheck(<strong>this</strong>) <strong>then</strong> </td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong>raise</strong> error('call paging error'); }</td>
</tr>
<tr>
<td>&nbsp; <strong>doc</strong> { 'Call  Subroutine. First, the 13-bit return address (PC+1) is pushed onto the stack&hellip;'};</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;  <strong>end class;</strong></span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp; <strong>class</strong> file</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp; <strong>constructor</strong> { <strong>reserve</strong>(1); }</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  <strong>instruction</strong> inc</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  {(B'00 1010 1000 0000' | (<strong>this</strong> &amp; B'00 0000 0111  1111' )); };</span></td>
</tr>
<tr>
<td><strong>&nbsp; sim </strong>{ <strong>if</strong> ! bankCheck(<strong>this</strong>) <strong>then</strong> <strong>raise</strong> error('banking error'); }</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  <strong>instruction</strong> '+=' (<strong>const</strong> 1)</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  {<strong> this.inc</strong>; }</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;  <strong>end class;</strong></span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>end device</strong>;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>application </strong>myapp <strong>for</strong> PIC16F84;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp; <strong>class</strong> mycount <strong>extends</strong> <strong>private</strong> file</span></td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp; <strong>doc</strong> {  'mycount is a GPR with restricted access')</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp; <strong>public instruction</strong> inc;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>&nbsp;  end class;</strong></span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>&nbsp;  data</strong> mydata { mycount myvar; };</span></td>
</tr>
<tr>
<td>&nbsp; <strong>if</strong> pic.banks[3].present <strong>then</strong> mydata.bank :=&nbsp; pic.banks[3];</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>&nbsp;  code </strong>{</span></td>
</tr>
<tr>
<td><strong>&nbsp; sim </strong>{ <strong>if</strong> myvar.value  &lt;&gt; 0 <strong>then</strong> </td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp; <strong>debug.print </strong>'myvar is not initialized!'; }</td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>&nbsp;&nbsp;&nbsp;  label</strong> there;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp; nop; nop;</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; ">&nbsp;&nbsp;&nbsp;  myvar <strong>+=</strong> 1; </span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray;">&nbsp;&nbsp;&nbsp; there.go; }</span></td>
</tr>
<tr>
<td bgcolor="#F3F3F3"><span style="color:gray; "><strong>end application;</strong> </span></td>
</tr>
</table>
<p></code></td>
</tr>
</table>
<p>&nbsp;</p>
<div>
<div id="ftn1">
<p><a href="#_ftnref1" name="_ftn1" title="" id="_ftn1"><sup>1</sup></a>In the traditional approaches a linker (loader) picks a &#8216;good enough&#8217; space for each section and places codes in that space. Then it goes trough a fixup-table and adjusts instructions according to actual addresses. e# will implement a different technique &ndash; since all build steps (assembling, linking, etc) will be performed in a single run, the linker routine will operate on the same internal representation of object created by the compiler routine</p>
</p></div>
<div id="ftn2">
<p><a href="#_ftnref2" name="_ftn2" title="" id="_ftn2"><sup>2</sup></a>In this example I did not use postfix form &#8216;++&#8217; intentionally, in my opinion this kind of syntax does not improve readability.</p>
</p></div>
<div id="ftn3">
<p><a href="#_ftnref3" name="_ftn3" title="" id="_ftn3"><sup>3</sup></a>I am not aware about existence of such in the real world</p>
</p></div>
</div>
<div id="ftn4">
<p><a href="#_ftnref4" name="_ftn4" title="" id="_ftn3"><sup>4</sup></a>Documentation samples are taken from PICmicro?„? Mid-Range MCU Family Reference Manual</p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/e/e-language-vision-as-an-embryonic-development-story/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Benefits of using e#</title>
		<link>http://hutorny.in.ua/projects/e/benefits-of-using-e</link>
		<comments>http://hutorny.in.ua/projects/e/benefits-of-using-e#comments</comments>
		<pubDate>Sat, 02 Sep 2006 19:11:21 +0000</pubDate>
		<dc:creator>Eugene</dc:creator>
				<category><![CDATA[e#]]></category>

		<guid isPermaLink="false">http://hutorny.in.ua/projects/e/benefits-of-using-e</guid>
		<description><![CDATA[I envision the following benefits of using e# It will allow writing better quality code in shorter time It will reduce maintenance cost by providing abilities for regression testing (on a simulator or in-circuit debugger) It will reduce impact of migrating to another device/platform e# will be more restrictive to human errors and misusages. It [...]]]></description>
			<content:encoded><![CDATA[<p>I envision the following benefits of using <span class="e3">e#</span></p>
<ol start="1" type="1">
<li>It will allow writing better quality code in shorter time</li>
<li>It will reduce maintenance cost by providing abilities for regression testing (on a simulator or in-circuit debugger)</li>
<li>It will reduce impact of migrating to another device/platform</li>
</ol>
<p><span id="more-71"></span></p>
<p><span class="e3">e#</span> will be more restrictive to human errors and misusages. It will generate errors at places where a regular assembler gives no warning, such as use of literal instead of address (<code>movf myconst,F</code>) use of improper address (goto myvar), using a flag on a wrong register (bsf OPTION,GIE) and so on.</p>
<p></p>
<p><span class="e3">e#</span> will provide facilities for &#8216;in-place&#8217; validation which can be performed in scope of a simulator run or under an in-circuit debugger. For example, each call to a square root routine can be validated against square root calculated by the e# builder upon actual parameters passed to the routine. Developer will be able to program such validations in e# and apply appropriate action if an invalid condition is detected (log a message, raise an exception, etc.). Another example ??“ a delay routine can be validated against expected delay.</p>
<p></p>
<p><span class="e3">e#</span> will provide facilities for automated testing (unit, integration, etc). Once established, these tests can be used for regression testing, allowing early problem detection when a new firmware version is in work (application maintenance) or when application is being moved to another target device (migration). These facilities will provide great help for debugging code, although they will not replace a visualized interactive debugger.</p>
<p><span class="e3">e#</span> will give ability to use essential level of abstractions when designing and implementing applications and still giving developers full control on costs and penalties contributed by those abstractions. For example, developer will be able to define a &#8216;function call abstraction&#8217; and implement proper mechanism for passing parameters and returning the result. Once it is done, the function call can be used in a similar way it is used on HLL and compiler will control if it is used as designed at syntax level, while developer may program code to verify it at semantic level.</p>
<p></p>
<p><span class="e3">e#</span> will provide ability to program for an &#8216;abstract MCU&#8217;. Yes, I know, MCUs are different, but nevertheless, I believe, it is possible to define a generic MCU model with a most common set of registers and instructions, such as load a literal, move, add, subtract, branch etc. This generic MCU model will not be generating any machine instructions leaving this responsibility to a model of a real-world MCU used in the application. A library routine (such as 16-bit wide addition), written for an abstract 8-bit MCU it terms of abstract MCU instructions, will be instantiated in the application with instructions, provided by the model of actually used MCU.</p>
<p></p>
<p><span class="e3">e#</span> will provide another way of delivering device notices, cautions, silicon errata to the developer. Until explicitly suppressed each notice associated with the device will be printed to the compiler output. These notices may have complex logic for determining if the underlying issue affects the application. This will help identifying problems before they happen and will simplify the migration path.</p>
<p></p>
<p><span class="e3">e#</span> MCU model will be yet another source to learn the target device either by inspecting the model source or by exploring the device in IDE. Since the model will be defined in a programming language and accessible to IDE as a set of objects, exposing the model to IDE will be a rather routine task.</p>
<p></p>
<p><span class="e3">e#</span> will provide facilities to control object vs resource allocation, eliminating need of separate linkers with their own &#8216;kind-of-a-language&#8217;.</p>
<p></p>
<p><span class="e3">e#</span> will be better suitable for modular and/or OO design providing essential facilities for modularity, encapsulation, and objectivity.</p>
<p></p>
<p><span class="e3">e#</span> will provide ability to debug process of code generation</p>
<p></p>
<p>Besides features not yet available in other languages, <span class="e3">e#</span> will address several shortcomings of assembly and C languages.</p>
<p><a href="#table1" name="table1" title=""></a>Table 1.<span class="e3">e#</span> vs ASM and C</p>
<table border=1 cellspacing=0 cellpadding=0 style="border-collapse:collapse;border:none;">
<tr>
<th width=199 valign=top><em>Language feature</em>
  </th>
<th width=132 valign=top align=center>ASM
  </th>
<th width=132 valign=top align=center>C+ASM
  </th>
<th width=132 valign=top align=center>C
  </th>
<th width=121 valign=top align=center><span class="e3">e#</span>
 </th>
</tr>
<tr>
<td>Syntax control</td>
<td valign=top align=center>poor</td>
<td valign=top align=center>poor</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center><strong>good</strong></td>
</tr>
<tr>
<td valign=top>Modularity</td>
<td valign=top align=center>poor</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center><strong>good</strong></td>
</tr>
<tr>
<td valign=top>High-level abstractions</td>
<td valign=top align=center>poor</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center><strong>good</strong></td>
</tr>
<tr>
<td valign=top>Access to the device model</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center><strong>good</strong></td>
</tr>
<tr>
<td valign=top>Low-level coding (in instructions)</td>
<td valign=top align=center>good</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center>poor</td>
<td valign=top align=center><strong>good</strong></td>
</tr>
<tr>
<td valign=top>Access to link-time variables</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center>moderate</td>
<td valign=top align=center>poor</td>
<td valign=top align=center><strong>good</strong></td>
</tr>
<tr>
<td valign=top>&quot;Transparency&quot; of generated code</td>
<td valign=top align=center>good</td>
<td valign=top align=center>poor</td>
<td valign=top align=center>poor</td>
<td valign=top align=center><strong>good</strong></td>
</tr>
<tr>
<td valign=top>Portability</td>
<td valign=top align=center>poor</td>
<td valign=top align=center>poor</td>
<td valign=top align=center>good</td>
<td valign=top align=center><strong>good</strong><a href="#_ftn1" name="_ftnref1" title=""><sup>1</sup></a></td>
</tr>
</table>
<p><a href="#_ftnref1" name="_ftn1" title=""><sup>1</sup></a> e# will not solve efficiency vs. portability dilemma, however, it will shift this solution from the tool selection stage to the design and implementation stage.</p>
]]></content:encoded>
			<wfw:commentRss>http://hutorny.in.ua/projects/e/benefits-of-using-e/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

