208 lines
12 KiB
HTML
208 lines
12 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>CONFIGPIN</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">CONFIGPIN</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/ConfigpinEx.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">CONFIGPIN Example</a>
|
||
</p>
|
||
<p> </p>
|
||
</div>
|
||
<p class="clear"> </p>
|
||
<p> </p>
|
||
<p class="PlainText">Syntax: <span class="keyword_in_text">CONFIGPIN</span> <![CDATA[ ]]><i>Mode</i>, <i>PinMask</i></p>
|
||
<h2>Function</h2>
|
||
<p class="PlainText">Configure special properties of I/O pins.
|
||
|
||
</p>
|
||
<ul>
|
||
<li value="1"><b><i>Mode</i></b>  is a variable/constant/expression (0 – 3), or one
|
||
of four predefined symbols, that specifies the I/O pin property to configure:
|
||
Schmitt Trigger, Logic Threshold, Pull-up Resistor or Output Direction. See
|
||
table below for an explanation of <i>Mode</i> values.</li>
|
||
<li value="2"><b><i>PinMask</i></b>  is a variable/constant/expression (1 – 65535)
|
||
that indicates how <i>Mode</i> is applied to I/O pins. Each bit of
|
||
<i>PinMask</i> corresponds to an individual I/O pin. A high bit (1) enables
|
||
the <i>Mode</i> and a low bit (0) disables the <i>Mode</i> on the
|
||
corresponding I/O pin.</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="4" bgcolor="#CFCFCF"><i>Mode</i> Values</td>
|
||
<td>0 (or SCHMITT): Schmitt Trigger</td>
|
||
</tr>
|
||
<tr>
|
||
<td>1 (or THRESHOLD): Logic Threshold</td>
|
||
</tr>
|
||
<tr>
|
||
<td>2 (or PULLUP): Pull-up Resistor</td>
|
||
</tr>
|
||
<tr>
|
||
<td>3 (or DIRECTION): Output Direction</td>
|
||
</tr>
|
||
<tr>
|
||
<td align="center" bgcolor="#CFCFCF">Related Commands</td>
|
||
<td align="center" colspan="1">
|
||
<p colspan="1" align="center"><a href="INPUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">INPUT</a>, <a href="OUTPUT.htm" target="" title="" alt="" class="MCXref_0" xrefformat="{paratext}">OUTPUT</a></p>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<h2>Explanation</h2>
|
||
<p class="PlainText">The <span class="keyword_in_text">CONFIGPIN</span> command enables or disables special I/O pin properties
|
||
on all 16 I/O pins at once. There are four properties, or modes, available:
|
||
Schmitt Trigger, Logic Threshold, Pull-up Resistor, and Output Direction.
|
||
Each I/O pin on the BS2px contains special hardware dedicated to each of
|
||
these properties.</p>
|
||
<p class="PlainText">By default, all BASIC Stamp I/O pins are set to inputs. Enabling the
|
||
Output Direction mode sets an I/O pin’s direction to output. Disabling
|
||
the Output Direction mode sets an I/O pin’s direction to input. This has
|
||
the same effect as using the <span class="keyword_in_text">OUTPUT</span> or <span class="keyword_in_text">INPUT</span> commands, or the
|
||
DIRx = # assignment statement to configure I/O pin directions. The
|
||
following is an example of the <span class="keyword_in_text">CONFIGPIN</span> command using the Output
|
||
Direction mode:</p><pre class="BScode" xml:space="preserve">
|
||
CONFIGPIN DIRECTION, %0000000100010011
|
||
</pre>
|
||
<p class="PlainText">Every high bit (1) in the <i>PinMask</i> argument enables the output direction
|
||
for the corresponding I/O pin while every low bit (0) disables the output
|
||
direction. In the above example, I/O pins 8, 4, 1, and 0 are set to the
|
||
output direction and all other I/O pins are set to the input direction. This
|
||
is similar to the following statement:</p><pre class="BScode" xml:space="preserve">
|
||
DIRS = %0000000100010011
|
||
</pre>
|
||
<p class="PlainText">Pull-up resistors are commonly used in circuitry where a component, such
|
||
as a button, provides an open/drain signal; the signal is either floating
|
||
(open) or is driven to ground (drain). Since the BASIC Stamp input pins
|
||
must always be connected to either 5 volts or ground (0 volts) in order to
|
||
read a reliable logic state with them, a pull-up resistor is required on
|
||
circuitry, such as the button circuit mentioned above, so that the signal is
|
||
never left floating (electrically disconnected).</p>
|
||
<p class="PlainText">The following example enables internal pull-up resistors on I/O pins 15,
|
||
12, 6, and 3, and disables internal pull-up resistors on all other I/O pins:</p><pre class="BScode" xml:space="preserve">
|
||
CONFIGPIN PULLUP, %1001000001001000
|
||
</pre>
|
||
<p class="PlainText">Note that the internal pull-up resistors are intentionally weak, about 20
|
||
kΩ. Additionally, the internal pull-up resistors can be activated for all
|
||
pins, regardless of pin direction, but really matter only when the
|
||
associated pin is set to input mode.</p>
|
||
<p class="PlainText">An input pin’s logic threshold determines the voltage levels that are
|
||
interpreted as logic high (1) and logic low (0). Most microcontrollers, and
|
||
other integrated circuits use one of two types of logic threshold: TTL Level
|
||
or CMOS Level. The BASIC Stamp I/O pins are, by default, configured for TTL
|
||
level logic thresholds. The figure below is an illustration of the difference
|
||
between TTL and CMOS logic levels.</p>
|
||
<table border="0">
|
||
<tr>
|
||
<td>
|
||
<img src="../../graphics/level_ttl.gif" border="0">
|
||
</img>
|
||
</td>
|
||
<td>         </td>
|
||
<td>
|
||
<img src="../../graphics/level_cmos.gif" border="0">
|
||
</img>
|
||
</td>
|
||
</tr>
|
||
<tr align="center">
|
||
<td><b>TTL Logic Level</b>
|
||
</td>
|
||
<td>   </td>
|
||
<td><b>CMOS Logic Level</b>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<p class="PlainText"> </p>
|
||
<p class="PlainText">The logic threshold for TTL is 1.4 volts; a voltage below 1.4 is considered
|
||
to be a logic 0 while a voltage above 1.4 is considered to be a logic 1. The
|
||
logic threshold for CMOS is 50% of Vdd; a voltage below ½ Vdd is
|
||
considered a logic 0 while a voltage above ½ Vdd is considered a logic 1.</p>
|
||
<p class="PlainText">For the <span class="keyword_in_text">CONFIGPIN</span> command's THRESHOLD mode, a high bit (1) in the
|
||
<i>PinMask</i> argument sets the corresponding I/O pin to CMOS threshold
|
||
level, and a low bit sets it to a TTL threshold level. The following example
|
||
sets CMOS threshold level on I/O pins 3, 2, 1, and 0, and TTL threshold
|
||
level on all other I/O pins.</p><pre class="BScode" xml:space="preserve">
|
||
CONFIGPIN THRESHOLD, %0000000000001111
|
||
</pre>
|
||
<p class="PlainText">The threshold level can be set for all pins, regardless of pin direction, but
|
||
really matters only when the associated pin is set to input mode.</p>
|
||
<p class="PlainText">Normally, if a signal on an input pin is somewhat noisy (the voltage level
|
||
randomly rises and falls beyond the logic threshold boundary) then
|
||
reading that pin’s input value will result in spurious highs and lows (1s
|
||
and 0s). Schmitt Triggers are circuits that make inputs more steady and
|
||
reliable by adding a region of hysteresis around the logic threshold that
|
||
the signal must completely traverse before the logic level is interpreted as
|
||
being changed. By default BASIC Stamp I/O pins are set to normal input
|
||
mode, but the BS2px can be configured for Schmitt Trigger mode as well.
|
||
The figure below illustrates Schmitt Trigger characteristics.</p>
|
||
<table border="0">
|
||
<tr>
|
||
<td>
|
||
<img src="../../graphics/level_schmitt.gif" border="0">
|
||
</img>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<p class="PlainText">In Schmitt Trigger mode, the threshold for a logic 0 is approximately 15%
|
||
of Vdd and the threshold for a logic 1 is approximately 85% of Vdd. The
|
||
input pin defaults to an unknown state until the initial voltage crosses a
|
||
logic 0 or logic 1 boundary. Thereafter, the voltage must cross above 85%
|
||
of Vdd to be interpreted as a logic 1 and must cross below 15% of Vdd to
|
||
be interpreted as a logic 0. If the voltage transitions somewhere between
|
||
the two thresholds, the interpreted logic state remains the same as the
|
||
previous state.</p>
|
||
<p class="PlainText">For the <span class="keyword_in_text">CONFIGPIN</span> command’s SCHMITT mode, a high bit (1) in the
|
||
<i>PinMask</i> argument enables the Schmitt Trigger on the corresponding I/O
|
||
pin and a low bit (0) disables the Schmitt Trigger. The following example
|
||
sets Schmitt Triggers on I/O pins 7, 6, 5, and 4, and sets all other I/O pins
|
||
to normal mode.</p><pre class="BScode" xml:space="preserve">
|
||
CONFIGPIN SCHMITT, %0000000011110000
|
||
</pre>
|
||
<p class="PlainText">Schmitt Trigger mode can be activated for all pins, regardless of pin
|
||
direction, but really matters only when the associated pin is set to input
|
||
mode.</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> |