144 lines
9.1 KiB
HTML
144 lines
9.1 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:lastBlockDepth="6" MadCap:lastHeight="94" MadCap:lastWidth="853" MadCap:disableMasterStylesheet="true" MadCap:tocPath="" MadCap:InPreviewMode="false" MadCap:PreloadImages="false" MadCap:RuntimeFileType="Topic" MadCap:TargetType="WebHelp" lang="en-us" xml:lang="en-us" MadCap:PathToHelpSystem="../../../" MadCap:HelpSystemFileName="Default.xml" MadCap:SearchType="Stem">
|
|
<head><title>POLLRUN</title>
|
|
<link href="../../SkinSupport/MadCap.css" rel="stylesheet" />
|
|
<link href="../../Resources/Stylesheets/BSE_Help.css" rel="stylesheet" />
|
|
<script src="../../SkinSupport/MadCapAll.js" type="text/javascript">
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1 class="code">POLLRUN</h1>
|
|
<div class="ImagePlusCaption">
|
|
<div class="Col2">
|
|
<p>
|
|
<img src="../../graphics/pgm_icon2p.gif" border="0" alt="BS2p icon" title="BS2p icon" />
|
|
<img src="../../graphics/pgm_icon2pe.gif" border="0" alt="BS2pe icon" title="BS2pe icon" />
|
|
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
|
</p>
|
|
</div>
|
|
<p style="text-align: right;"><a href="../ExampleTopics/PollrunEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLRUN Example</a>
|
|
</p>
|
|
<p> </p>
|
|
</div>
|
|
<p class="clear"> </p>
|
|
<p> </p>
|
|
<p class="PlainText">Syntax: <span class="keyword_in_text">POLLRUN</span> <![CDATA[ ]]><i>ProgramSlot</i></p>
|
|
<h2>Function</h2>
|
|
<p class="PlainText">Specify a program to run upon a polled-input event.
|
|
|
|
</p>
|
|
<ul>
|
|
<li value="1"><b><i>ProgramSlot</i></b> is a variable/constant/expression (0 - 7) that
|
|
specifies the program slot to run when a polled-input event occurs.</li>
|
|
</ul>
|
|
<h2>Quick Facts</h2>
|
|
<table width="100%" cellpadding="4" cellspacing="0" border="1">
|
|
<tr>
|
|
<td width="20%" align="center" bgcolor="#CFCFCF"> </td>
|
|
<td width="80%" align="center" bgcolor="#CFCFCF">BS2p, BS2pe, and BS2px</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" bgcolor="#CFCFCF">Default Slot</td>
|
|
<td align="left">The default polled-run slot is 0. If no <span class="keyword_in_text">POLLRUN</span>
|
|
command is given and a poll mode of 3 or 4 is set, the program in slot 0
|
|
will run in response to a polled-input event.</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" bgcolor="#CFCFCF">Special Notes</td>
|
|
<td align="left">
|
|
<ul>
|
|
<li value="1">If both polled-outputs and polled-run are active, the polled-output
|
|
event will occur before the polled-run event.
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
|
|
<td align="center" colspan="1">
|
|
<p colspan="1" align="center"><a href="POLLIN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLIN</a>, <a href="POLLMODE.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLMODE</a>, <a href="POLLOUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLOUT</a>, <a href="POLLWAIT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">POLLWAIT</a>, <a href="RUN.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">RUN</a></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
<h2>Explanation</h2>
|
|
<p class="PlainText">The <span class="keyword_in_text">POLLRUN</span> command is one of a family of unique "polling" commands on the
|
|
BS2p, BS2pe, and BS2px modules. The other commands in this family include <span class="keyword_in_text">POLLIN</span>,
|
|
<span class="keyword_in_text">POLLMODE</span>, <span class="keyword_in_text">POLLOUT</span> and <span class="keyword_in_text">POLLWAIT</span>. The <span class="keyword_in_text">POLLRUN</span> command
|
|
is used to specify a program slot to run in response to a polled event. This
|
|
activity can occur in between any two instructions within the rest of the PBASIC
|
|
program.</p>
|
|
<p class="PlainText">The "polling" commands allow the BASIC Stamp to respond to certain I/O pin
|
|
events at a faster rate than what is normally possible through manual PBASIC
|
|
programming. The term "poll" comes from the fact that the BASIC Stamp's interpreter
|
|
periodically checks the state of the designated polled-input pins. It "polls"
|
|
these pins after the end of each PBASIC instruction and before it reads the next
|
|
PBASIC instruction from the user program; giving the appearance that it is polling
|
|
"in the background". This feature should not be confused with the concept of
|
|
interrupts, as the BASIC Stamp does not support true interrupts.</p>
|
|
<p class="PlainText">The following is a simple example of the <span class="keyword_in_text">POLLRUN</span> command:</p><pre class="BScode" xml:space="preserve">
|
|
Setup:
|
|
POLLIN 0, 0
|
|
POLLRUN 1
|
|
POLLMODE 3
|
|
|
|
Main:
|
|
DEBUG "Waiting in Program Slot 0...", CR
|
|
GOTO Main
|
|
</pre>
|
|
<p class="PlainText">The first line of the above code will set up I/O pin 0 as a polled-input pin
|
|
looking for a low (0) state. The second line, <span class="keyword_in_text">POLLRUN</span>, tells the BASIC
|
|
Stamp that when I/O pin 0 goes low, it should switch execution over to the
|
|
program residing in program slot 1. The third line, <span class="keyword_in_text">POLLMODE</span>, activates
|
|
the polled-run configuration.</p>
|
|
<p class="PlainText">Once the BASIC Stamp reaches the Main routine, it will continuously print
|
|
"Waiting in Program Slot 0..." on the PC screen. In between reading the
|
|
<span class="keyword_in_text">DEBUG</span> and <span class="keyword_in_text">GOTO</span> commands, however, the BASIC Stamp will poll I/O
|
|
pin 0 and check for a high or low state. If the state of pin 0 is high,
|
|
it will do nothing and continue as normal. If the state of pin 1 is low, it
|
|
will switch execution over to the program in slot 1 (the second program is not
|
|
shown in this example). The switch to another program slot works exactly like
|
|
with the <span class="keyword_in_text">RUN</span> command; the designated program is run and the BASIC Stamp
|
|
does not "return" to the previous program (similar to a <span class="keyword_in_text">GOTO</span> command).</p>
|
|
<p class="PlainText">Note that in order for the polled-run activity to occur, the poll mode must
|
|
be set to either 3 or 4 (the two modes that activate polled-run). Also note,
|
|
that the polled-run modes, 3 and 4, are unique. As soon as the polled-run action
|
|
occurs, the mode switches to 1 (deactivated, saved) or 2 (activated, outputs),
|
|
respectively. This is so that the BASIC Stamp doesn't continuously go to the
|
|
start of the designated program slot while the polled-inputs are in the desired
|
|
poll state. Without this "one shot" feature, your program would appear to lock-up
|
|
as long as the polled-inputs are in the designated state.</p>
|
|
<p class="PlainText">After the program switch takes place, the <i>ProgramSlot</i> value is maintained.
|
|
Any future change to poll mode 3 or 4, without another <span class="keyword_in_text">POLLRUN</span> command, will
|
|
result in the previously defined program slot being used.</p>
|
|
<div class="Col2">
|
|
<div class="MasterFoot">
|
|
<p MadCap:conditions="BSEconditions.BSEWebHelp (Primary)-INCLUDE"><a href="../../HomeTopics/HomePage.htm">Go to Welcome page</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="Col2">
|
|
<div class="MasterFoot">
|
|
<p style="text-align: right;"><span class="ContactInfoProjectName">BASIC Stamp Help</span> <![CDATA[ ]]><span class="ContactInfoVersion#">Version 2.5.4</span> <![CDATA[ ]]></p>
|
|
<p style="text-align: right;">Copyright © <span class="ContactInfoCompanyName">Parallax Inc.</span></p>
|
|
<p style="text-align: right;"><span class="SystemShortDate">8/8/2012</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">/* <![CDATA[ */
|
|
|
|
var _gaq = _gaq || [];
|
|
_gaq.push(['_setAccount', 'UA-285614-1']);
|
|
_gaq.push(['_trackPageview']);
|
|
|
|
(function() {
|
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
})();
|
|
|
|
/* ]]> */</script>
|
|
<script type="text/javascript" src="../../SkinSupport/MadCapBodyEnd.js">
|
|
</script>
|
|
</body>
|
|
</html> |