117 lines
6.4 KiB
HTML
117 lines
6.4 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>COMPARE</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">COMPARE</h1>
|
|||
|
<div class="ImagePlusCaption">
|
|||
|
<div class="Col2">
|
|||
|
<p>
|
|||
|
<img src="../../graphics/pgm_icon2px.gif" border="0" alt="BS2px icon" title="BS2px icon" />
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
<p style="text-align: right;"><a href="../ExampleTopics/CompareEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">COMPARE Example</a>
|
|||
|
</p>
|
|||
|
<p> </p>
|
|||
|
</div>
|
|||
|
<p class="clear"> </p>
|
|||
|
<p> </p>
|
|||
|
<p class="PlainText">Syntax: <span class="keyword_in_text">COMPARE</span> <![CDATA[ ]]><i>Mode,</i> <![CDATA[ ]]><i>Result</i></p>
|
|||
|
<h2>Function</h2>
|
|||
|
<p>Enable or disable comparator, compare voltages on P1 and P2 and retrieve
|
|||
|
comparison result to store in <i>Result</i>.
|
|||
|
|
|||
|
</p>
|
|||
|
<ul>
|
|||
|
<li value="1"><b><i>Mode</i></b> is a variable/constant/expression (0 – 2) that enables
|
|||
|
or disables the comparator (input pins P1 and P2) and determines if the
|
|||
|
optional comparator output pin (pin P0) is enabled or not. See the table
|
|||
|
below for an explanation of the <i>Mode</i> values.</li>
|
|||
|
<li value="2"><b><i>Result</i></b> is a variable (usually a bit) in which the
|
|||
|
comparison result is stored.</li>
|
|||
|
</ul>
|
|||
|
<h2>Quick Facts<br /></h2>
|
|||
|
<table width="100%" cellpadding="4" cellspacing="0" border="1">
|
|||
|
<tr bgcolor="#CFCFCF">
|
|||
|
<td width="80" align="center"> </td>
|
|||
|
<td width="80%%" align="center">BS2px</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center" rowspan="3" bgcolor="#CFCFCF"><i>Mode</i> Values</td>
|
|||
|
<td>0: Disables comparator.</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>1: Enables comparator with P0 as <i>Result</i> output.</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>2: Enables comparator without P0 as <i>Result</i> output.</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td align="center" rowspan="2" bgcolor="#CFCFCF"><i>Result</i> Values</td>
|
|||
|
<td>0: Voltage P1 > P2; P0 optionally outputs 0.</td>
|
|||
|
</tr>
|
|||
|
<tr>
|
|||
|
<td>1: Voltage P1 < P2; P0 optionally outputs 1.</td>
|
|||
|
</tr>
|
|||
|
</table>
|
|||
|
<h2>Explanation</h2>
|
|||
|
<p class="PlainText">The <span class="keyword_in_text">COMPARE</span> command enables or disables the built-in comparator
|
|||
|
hardware on the BS2px's I/O pins P0, P1, and P2. I/O pins P1 and P2 are
|
|||
|
the comparator inputs and P0 is optionally the comparator result output
|
|||
|
pin.</p>
|
|||
|
<p class="PlainText">By default, the comparator feature is disabled. Using the <span class="keyword_in_text">COMPARE</span> command with a <i>Mode</i> argument of 1 or 2 enables the comparator feature
|
|||
|
(using input pins P1 and P2) and returns the result of the comparison in
|
|||
|
<i>Result</i>. If <i>Mode</i> is 1, the result of the comparison is also
|
|||
|
output on I/O pin P0. The following is an example of the <span class="keyword_in_text">COMPARE </span>command:</p><pre class="BScode" xml:space="preserve">
|
|||
|
result VAR Bit
|
|||
|
|
|||
|
Main:
|
|||
|
COMPARE 1, result
|
|||
|
</pre>
|
|||
|
<p class="PlainText">This example enables the comparator (setting P0 to output the result,
|
|||
|
with P1 and P2 as the comparator inputs) and writes the result of the
|
|||
|
comparison into <i>result</i>. Both <i>Result </i>and the output pin P0
|
|||
|
will be 0 if the input voltage on P1 was greater than that of P2.
|
|||
|
<i>result</i> and the output pin P0 will be 1 if the input voltage on P1
|
|||
|
was less than that of P2.</p>
|
|||
|
<p class="PlainText">Note that the comparator hardware operates independently of the
|
|||
|
execution speed of the BS2px and will continue to run and update P0 if
|
|||
|
Mode = 1, even during sleep mode (execution of <span class="keyword_in_text">END</span>, <span class="keyword_in_text">NAP</span>,
|
|||
|
<span class="keyword_in_text">POLLWAIT</span> 8, or <span class="keyword_in_text">SLEEP</span> commands). To avoid spurious current
|
|||
|
draw during sleep mode, disable the comparator first.</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>
|