<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=NU32v2%3A_Digital_Input_and_Output</id>
	<title>NU32v2: Digital Input and Output - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://hades.mech.northwestern.edu//index.php?action=history&amp;feed=atom&amp;title=NU32v2%3A_Digital_Input_and_Output"/>
	<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;action=history"/>
	<updated>2026-05-23T17:25:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=23705&amp;oldid=prev</id>
		<title>Lynch at 11:22, 16 January 2016</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=23705&amp;oldid=prev"/>
		<updated>2016-01-16T11:22:50Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 06:22, 16 January 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;THIS PAGE REFERS TO A PRE-RELEASE VERSION OF THE NU32 PIC32 DEVELOPMENT BOARD.  FOR INFORMATION, SAMPLE CODE, AND VIDEOS RELATED TO THE PRODUCTION VERSION (2016 AND LATER), AND TO THE CORRESPONDING BOOK &quot;EMBEDDED COMPUTING AND MECHATRONICS WITH THE PIC32 MICROCONTROLLER,&quot; VISIT [[NU32|THE NU32 PAGE]].&#039;&#039;&#039;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-empty diff-side-deleted&quot;&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Digital inputs and outputs (DIO) are the simplest of interfaces between the PIC and other electronics, sensors, and actuators.  The PIC32 has many DIO pins, each of which can take one of two states:  high or low.  &lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Digital inputs and outputs (DIO) are the simplest of interfaces between the PIC and other electronics, sensors, and actuators.  The PIC32 has many DIO pins, each of which can take one of two states:  high or low.  &lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19925&amp;oldid=prev</id>
		<title>Lynch: /* Details */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19925&amp;oldid=prev"/>
		<updated>2011-01-27T16:56:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Details&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:56, 27 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;ODCx&#039;&#039;&#039;: &amp;lt;tt&amp;gt;ODCB = 0x00FF&amp;lt;/tt&amp;gt; configures RB0..RB7 as open drain, and pins RB8..RB15 as typical buffered output.  An individual pin can be referenced as ODCBbits.ODCB8, for example.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;ODCx&#039;&#039;&#039;: &amp;lt;tt&amp;gt;ODCB = 0x00FF&amp;lt;/tt&amp;gt; configures RB0..RB7 as open drain, and pins RB8..RB15 as typical buffered output.  An individual pin can be referenced as ODCBbits.ODCB8, for example.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;CNPUE&#039;&#039;&#039;:  The relevant bits of this SFR are CNPUE&amp;lt;21:0&amp;gt;, and they apply only to the 22 change notification pins CN0..CN21.  If CNPUEbits.CNPUE2 = 1, then the pin with CN2 function has the internal pull-up resistor enabled, and if CNPUEbits.CNPUE2 = 0, then it is disabled.  The command &amp;lt;tt&amp;gt;CNPUE = &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0xFFFFFF&lt;/del&gt;&amp;lt;/tt&amp;gt; enables the internal pull-up resistors for all CN pins.  The default has the pull-ups disabled.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;CNPUE&#039;&#039;&#039;:  The relevant bits of this SFR are CNPUE&amp;lt;21:0&amp;gt;, and they apply only to the 22 change notification pins CN0..CN21.  If CNPUEbits.CNPUE2 = 1, then the pin with CN2 function has the internal pull-up resistor enabled, and if CNPUEbits.CNPUE2 = 0, then it is disabled.  The command &amp;lt;tt&amp;gt;CNPUE = &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0xFFFFF&lt;/ins&gt;&amp;lt;/tt&amp;gt; enables the internal pull-up resistors for all CN pins.  The default has the pull-ups disabled.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a CLR register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB |= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a CLR register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB |= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19924&amp;oldid=prev</id>
		<title>Lynch at 16:53, 27 January 2011</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19924&amp;oldid=prev"/>
		<updated>2011-01-27T16:53:06Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:53, 27 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;CNPUE&#039;&#039;&#039;:  The relevant bits of this SFR are CNPUE&amp;lt;21:0&amp;gt;, and they apply only to the 22 change notification pins CN0..CN21.  If CNPUEbits.CNPUE2 = 1, then the pin with CN2 function has the internal pull-up resistor enabled, and if CNPUEbits.CNPUE2 = 0, then it is disabled.  The command &amp;lt;tt&amp;gt;CNPUE = 0xFFFFFF&amp;lt;/tt&amp;gt; enables the internal pull-up resistors for all CN pins.  The default has the pull-ups disabled.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;CNPUE&#039;&#039;&#039;:  The relevant bits of this SFR are CNPUE&amp;lt;21:0&amp;gt;, and they apply only to the 22 change notification pins CN0..CN21.  If CNPUEbits.CNPUE2 = 1, then the pin with CN2 function has the internal pull-up resistor enabled, and if CNPUEbits.CNPUE2 = 0, then it is disabled.  The command &amp;lt;tt&amp;gt;CNPUE = 0xFFFFFF&amp;lt;/tt&amp;gt; enables the internal pull-up resistors for all CN pins.  The default has the pull-ups disabled.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a CLR register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;^&lt;/del&gt;= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a CLR register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|&lt;/ins&gt;= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Other SFRs and their functions are described in Chapter 12 of the Reference Manual.  The C names of the SFRs, and the structures with their bit references, can be found in the file p32mx795f512l.h, which is under pic32-libs/include/proc.  The SET, CLR, and INV registers are described in Section 2 of the Reference Manual.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Other SFRs and their functions are described in Chapter 12 of the Reference Manual.  The C names of the SFRs, and the structures with their bit references, can be found in the file p32mx795f512l.h, which is under pic32-libs/include/proc.  The SET, CLR, and INV registers are described in Section 2 of the Reference Manual.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19923&amp;oldid=prev</id>
		<title>Nelson Rosa: /* Details */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19923&amp;oldid=prev"/>
		<updated>2011-01-27T16:38:08Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Details&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:38, 27 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 15:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;AD1PCFG&#039;&#039;&#039;:  This SFR determines which of the 16 pins with an analog input function (port B) is treated as an analog input or a DIO pin.  The 16 most significant bits (high bits) AD1PCFG&amp;lt;31:16&amp;gt; are ignored, but AD1PCFG&amp;lt;15:0&amp;gt; determine which of the 16 pins is treated as an analog input.  0 indicates analog input, and 1 indicates DIO.  So if the bit AD1PCFG&amp;lt;7&amp;gt; is 0, then the pin with the function AN7 is an analog input; if AD1PCFG&amp;lt;7&amp;gt; is 1, then it is a DIO.  AD1PCFG resets to 0x0000, so all 16 pins of port B are treated as analog inputs by default.  To make AN15 and AN1 analog inputs and the rest DIO, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG = 0x7FFD&amp;lt;/tt&amp;gt;.  To make AN15 and AN1 analog inputs but leave the other settings unchanged, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG &amp;amp;= 0x7FFD&amp;lt;/tt&amp;gt;.  Note we only have to specify 16 bits, or 4 hex digits, as the 16 most significant bits have no role.  Instead of acting on the entire SFR, we could instead address an individual bit, using &amp;lt;tt&amp;gt;AD1PCFGbits.PCFG15 = 1&amp;lt;/tt&amp;gt;, for example, to set the value of a single bit.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;AD1PCFG&#039;&#039;&#039;:  This SFR determines which of the 16 pins with an analog input function (port B) is treated as an analog input or a DIO pin.  The 16 most significant bits (high bits) AD1PCFG&amp;lt;31:16&amp;gt; are ignored, but AD1PCFG&amp;lt;15:0&amp;gt; determine which of the 16 pins is treated as an analog input.  0 indicates analog input, and 1 indicates DIO.  So if the bit AD1PCFG&amp;lt;7&amp;gt; is 0, then the pin with the function AN7 is an analog input; if AD1PCFG&amp;lt;7&amp;gt; is 1, then it is a DIO.  AD1PCFG resets to 0x0000, so all 16 pins of port B are treated as analog inputs by default.  To make AN15 and AN1 analog inputs and the rest DIO, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG = 0x7FFD&amp;lt;/tt&amp;gt;.  To make AN15 and AN1 analog inputs but leave the other settings unchanged, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG &amp;amp;= 0x7FFD&amp;lt;/tt&amp;gt;.  Note we only have to specify 16 bits, or 4 hex digits, as the 16 most significant bits have no role.  Instead of acting on the entire SFR, we could instead address an individual bit, using &amp;lt;tt&amp;gt;AD1PCFGbits.PCFG15 = 1&amp;lt;/tt&amp;gt;, for example, to set the value of a single bit.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;TRISx&#039;&#039;&#039;:  This SFR determines which of the DIO pins of port x are inputs and which are outputs.  For example, &amp;lt;tt&amp;gt;TRISBbits.TRISB5 = 0&amp;lt;/tt&amp;gt; makes RB5 an output (0 = Output), &amp;lt;tt&amp;gt;TRISBbits.TRISB5 = 1&amp;lt;/tt&amp;gt; makes RB5 an input (1 = Input), &amp;lt;tt&amp;gt;TRISB &amp;amp;= FF00&amp;lt;/tt&amp;gt; makes RB0..RB7 outputs while leaving the others unchanged, &amp;lt;tt&amp;gt;TRISB &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;^&lt;/del&gt;= FF00&amp;lt;/tt&amp;gt; makes RB8..RB15 inputs while leaving the others unchanged, and &amp;lt;tt&amp;gt;TRISB = FF00&amp;lt;/tt&amp;gt; makes RB0..RB7 outputs and RB8..RB15 inputs.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;TRISx&#039;&#039;&#039;:  This SFR determines which of the DIO pins of port x are inputs and which are outputs.  For example, &amp;lt;tt&amp;gt;TRISBbits.TRISB5 = 0&amp;lt;/tt&amp;gt; makes RB5 an output (0 = Output), &amp;lt;tt&amp;gt;TRISBbits.TRISB5 = 1&amp;lt;/tt&amp;gt; makes RB5 an input (1 = Input), &amp;lt;tt&amp;gt;TRISB &amp;amp;= FF00&amp;lt;/tt&amp;gt; makes RB0..RB7 outputs while leaving the others unchanged, &amp;lt;tt&amp;gt;TRISB &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|&lt;/ins&gt;= FF00&amp;lt;/tt&amp;gt; makes RB8..RB15 inputs while leaving the others unchanged, and &amp;lt;tt&amp;gt;TRISB = FF00&amp;lt;/tt&amp;gt; makes RB0..RB7 outputs and RB8..RB15 inputs.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;LATx&#039;&#039;&#039;:  A write to the latch chooses the output for pins configured as digital outputs.  For example, &amp;lt;tt&amp;gt;LATB = 0x00FF&amp;lt;/tt&amp;gt; makes pins RB0..RB7 high and pins RB8..RB15 low.  An individual pin can be referenced using LATBbits.LATB13, for example.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;LATx&#039;&#039;&#039;:  A write to the latch chooses the output for pins configured as digital outputs.  For example, &amp;lt;tt&amp;gt;LATB = 0x00FF&amp;lt;/tt&amp;gt; makes pins RB0..RB7 high and pins RB8..RB15 low.  An individual pin can be referenced using LATBbits.LATB13, for example.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Nelson Rosa</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19863&amp;oldid=prev</id>
		<title>Lynch: /* Details */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19863&amp;oldid=prev"/>
		<updated>2011-01-26T09:16:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Details&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:16, 26 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 25:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;CNPUE&#039;&#039;&#039;:  The relevant bits of this SFR are CNPUE&amp;lt;21:0&amp;gt;, and they apply only to the 22 change notification pins CN0..CN21.  If CNPUEbits.CNPUE2 = 1, then the pin with CN2 function has the internal pull-up resistor enabled, and if CNPUEbits.CNPUE2 = 0, then it is disabled.  The command &amp;lt;tt&amp;gt;CNPUE = 0xFFFFFF&amp;lt;/tt&amp;gt; enables the internal pull-up resistors for all CN pins.  The default has the pull-ups disabled.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;CNPUE&#039;&#039;&#039;:  The relevant bits of this SFR are CNPUE&amp;lt;21:0&amp;gt;, and they apply only to the 22 change notification pins CN0..CN21.  If CNPUEbits.CNPUE2 = 1, then the pin with CN2 function has the internal pull-up resistor enabled, and if CNPUEbits.CNPUE2 = 0, then it is disabled.  The command &amp;lt;tt&amp;gt;CNPUE = 0xFFFFFF&amp;lt;/tt&amp;gt; enables the internal pull-up resistors for all CN pins.  The default has the pull-ups disabled.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;CLEAR&lt;/del&gt; register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB ^= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;CLR&lt;/ins&gt; register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB ^= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Other SFRs and their functions are described in Chapter 12 of the Reference Manual.  The C names of the SFRs, and the structures with their bit references, can be found in the file p32mx795f512l.h, which is under pic32-libs/include/proc.  The SET, CLR, and INV registers are described in Section 2 of the Reference Manual.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Other SFRs and their functions are described in Chapter 12 of the Reference Manual.  The C names of the SFRs, and the structures with their bit references, can be found in the file p32mx795f512l.h, which is under pic32-libs/include/proc.  The SET, CLR, and INV registers are described in Section 2 of the Reference Manual.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19862&amp;oldid=prev</id>
		<title>Lynch: /* Sample Code */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19862&amp;oldid=prev"/>
		<updated>2011-01-26T09:13:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Sample Code&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 04:13, 26 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 185:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;and try the program again with each.  If you got the same results I did, you got a delay of about 11 seconds, 4 seconds, and just under 2 seconds, respectively, for the three cases.  This indicates that just configuring the peripheral bus does nothing for us.  This makes sense:  in our bootloader, we already set both the system clock and the peripheral bus clock to 80 MHz, which is the maximum possible frequency for both.  On the other hand, configuring the wait states gave us nearly a three times performance improvement.  This means that this optimization reduced (from the default) the number of cycles the CPU waits for information requested from the flash memory.  Finally, configuring the pre-fetch cache alone essentially gave us the entire speed-up.  The pre-fetch cache stores recent instructions fetched from flash (program) memory and keeps &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;it&lt;/del&gt; ready for use without flash wait states, and when possible, &quot;runs ahead&quot; to get future instructions so they are ready for the CPU without the flash wait cycles.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;and try the program again with each.  If you got the same results I did, you got a delay of about 11 seconds, 4 seconds, and just under 2 seconds, respectively, for the three cases.  This indicates that just configuring the peripheral bus does nothing for us.  This makes sense:  in our bootloader, we already set both the system clock and the peripheral bus clock to 80 MHz, which is the maximum possible frequency for both.  On the other hand, configuring the wait states gave us nearly a three times performance improvement.  This means that this optimization reduced (from the default) the number of cycles the CPU waits for information requested from the flash memory.  Finally, configuring the pre-fetch cache alone essentially gave us the entire speed-up.  The pre-fetch cache stores recent instructions fetched from flash (program) memory and keeps &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;them&lt;/ins&gt; ready for use without flash wait states, and when possible, &quot;runs ahead&quot; to get future instructions so they are ready for the CPU without the flash wait cycles.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== More Information ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== More Information ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19826&amp;oldid=prev</id>
		<title>Lynch: /* Library Functions */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19826&amp;oldid=prev"/>
		<updated>2011-01-25T15:37:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Library Functions&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:37, 25 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 79:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 79:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Library Functions ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Library Functions ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The peripheral library offers a number of function calls to help you use the DIO pins.  These functions have names such as &amp;lt;tt&amp;gt;PORTRead&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;PORTSetPinsDigitalIn&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;PORTSetPinsDigitalOut&amp;lt;/tt&amp;gt;, etc.  C source code can be found in pic32-libs/peripheral/ports/source/*.c, and .h header files can be found in pic32-libs/include/peripheral/ports.h.  The DIO functions are simple enough, however, that we will usually just set the appropriate SFRs manually, as described above and demonstrated in the samples below.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The peripheral library offers a number of function calls to help you use the DIO pins.  These functions have names such as &amp;lt;tt&amp;gt;PORTRead&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;PORTSetPinsDigitalIn&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;PORTSetPinsDigitalOut&amp;lt;/tt&amp;gt;, etc.  C source code can be found in pic32-libs/peripheral/ports/source/*.c, and .h header files can be found in pic32-libs/include/peripheral/ports.h&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.  Documentation can be found in your MPLAB C32&#039;s doc directory, in Microchip-PIC32MX-Peripheral-Library.chm&lt;/ins&gt;.  The DIO functions are simple enough, however, that we will usually just set the appropriate SFRs manually, as described above and demonstrated in the samples below.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Sample Code ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Sample Code ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19825&amp;oldid=prev</id>
		<title>Lynch: /* Details */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19825&amp;oldid=prev"/>
		<updated>2011-01-25T15:34:13Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Details&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:34, 25 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a CLEAR register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB ^= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Finally, each SFR (e.g., TRISB, LATD, PORTA, ODCC, etc.) has three more registers associated with it:  a SET register, a CLEAR register, and an INV register.  Writing to these registers allows atomic (single cycle) updating of the SFR contents, which is faster than reading the current value of the SFR, modifying it, and writing back to the SFR.  SET means that bits are set (made equal to 1), CLR means that bits are cleared (made equal to 0), and INV means that bits are inverted.  So &amp;lt;tt&amp;gt;TRISBCLR = 0x0110&amp;lt;/tt&amp;gt; will clear bits 4 and 8 and &amp;lt;tt&amp;gt;TRISBSET = 0x0110&amp;lt;/tt&amp;gt; will set bits 4 and 8.  All other bits (with a 0 on the right-hand side of the = sign) are unchanged.  For example, &amp;lt;tt&amp;gt;LATBSET = 0x0001&amp;lt;/tt&amp;gt; has the same effect as &amp;lt;tt&amp;gt;LATB ^= 0x0001&amp;lt;/tt&amp;gt;, but the former is faster.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Other SFRs and their functions are described in Chapter 12 of the Reference Manual.  The C names of the SFRs, and the &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;structrues&lt;/del&gt; with their bit references, can be found in the file p32mx795f512l.h, which is under pic32-libs/include/proc.  The SET, CLR, and INV registers are described in Section 2 of the Reference Manual.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Other SFRs and their functions are described in Chapter 12 of the Reference Manual.  The C names of the SFRs, and the &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;structures&lt;/ins&gt; with their bit references, can be found in the file p32mx795f512l.h, which is under pic32-libs/include/proc.  The SET, CLR, and INV registers are described in Section 2 of the Reference Manual.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;!-- &lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;!-- &lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19824&amp;oldid=prev</id>
		<title>Lynch: /* Details */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19824&amp;oldid=prev"/>
		<updated>2011-01-25T15:32:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Details&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:32, 25 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;LATx&#039;&#039;&#039;:  A write to the latch chooses the output for pins configured as digital outputs.  For example, &amp;lt;tt&amp;gt;LATB = 0x00FF&amp;lt;/tt&amp;gt; makes pins RB0..RB7 high and pins RB8..RB15 low.  An individual pin can be referenced using LATBbits.LATB13, for example.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;LATx&#039;&#039;&#039;:  A write to the latch chooses the output for pins configured as digital outputs.  For example, &amp;lt;tt&amp;gt;LATB = 0x00FF&amp;lt;/tt&amp;gt; makes pins RB0..RB7 high and pins RB8..RB15 low.  An individual pin can be referenced using LATBbits.LATB13, for example.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;PORTx&#039;&#039;&#039;:  &amp;lt;tt&amp;gt;val = PORTB&amp;lt;/tt&amp;gt; returns the current digital inputs for DIO pins configured as inputs.  PORTBbits.RB6 returns the digital input for RB6.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;PORTx&#039;&#039;&#039;:  &amp;lt;tt&amp;gt;val = PORTB&amp;lt;/tt&amp;gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, where val is an unsigned int,&lt;/ins&gt; returns the current digital inputs for DIO pins configured as inputs.  PORTBbits.RB6 returns the digital input for RB6.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;ODCx&#039;&#039;&#039;: &amp;lt;tt&amp;gt;ODCB = 0x00FF&amp;lt;/tt&amp;gt; configures RB0..RB7 as open drain, and pins RB8..RB15 as typical buffered output.  An individual pin can be referenced as ODCBbits.ODCB8, for example.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;ODCx&#039;&#039;&#039;: &amp;lt;tt&amp;gt;ODCB = 0x00FF&amp;lt;/tt&amp;gt; configures RB0..RB7 as open drain, and pins RB8..RB15 as typical buffered output.  An individual pin can be referenced as ODCBbits.ODCB8, for example.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
	<entry>
		<id>https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19823&amp;oldid=prev</id>
		<title>Lynch: /* Details */</title>
		<link rel="alternate" type="text/html" href="https://hades.mech.northwestern.edu//index.php?title=NU32v2:_Digital_Input_and_Output&amp;diff=19823&amp;oldid=prev"/>
		<updated>2011-01-25T15:29:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Details&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:29, 25 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 11:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Details ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Details ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The functions of the DIO pins are controlled by special function registers (SFRs).  Each of these SFRs has 32 bits on the PIC32, but for many, &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;only&lt;/del&gt; &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;16&lt;/del&gt; &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;of the bits&lt;/del&gt; are relevant.  Depending on whether these bits are set to 0 or 1, different actions or settings are performed:&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The functions of the DIO pins are controlled by special function registers (SFRs).  Each of these SFRs has 32 bits on the PIC32, but for many, &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;not&lt;/ins&gt; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;all&lt;/ins&gt; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;32&lt;/ins&gt; are relevant.  Depending on whether these bits are set to 0 or 1, different actions or settings are performed:&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;AD1PCFG&#039;&#039;&#039;:  This SFR determines which of the 16 pins with an analog input function (port B) is treated as an analog input or a DIO pin.  The 16 most significant bits (high bits) AD1PCFG&amp;lt;31:16&amp;gt; are ignored, but AD1PCFG&amp;lt;15:0&amp;gt; determine which of the 16 pins is treated as an analog input.  0 indicates analog input, and 1 indicates DIO.  So if the bit AD1PCFG&amp;lt;7&amp;gt; is 0, then the pin with the function AN7 is an analog input; if AD1PCFG&amp;lt;7&amp;gt; is 1, then it is a DIO.  AD1PCFG resets to 0x0000, so all 16 pins of port B are treated as analog inputs by default.  To make AN15 and AN1 analog inputs and the rest DIO, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG = 0x7FFD&amp;lt;/tt&amp;gt;.  To make AN15 and AN1 analog inputs but leave the other settings unchanged, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG &amp;amp;= 0x7FFD&amp;lt;/tt&amp;gt;.  Note we only have to specify 16 bits, or 4 hex digits, as the 16 most significant bits have no role.  Instead of acting on the entire SFR, we could instead address an individual bit, using &amp;lt;tt&amp;gt;AD1PCFGbits.PCFG15 = 1&amp;lt;/tt&amp;gt;, for example, to set the value of a single bit.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* &#039;&#039;&#039;AD1PCFG&#039;&#039;&#039;:  This SFR determines which of the 16 pins with an analog input function (port B) is treated as an analog input or a DIO pin.  The 16 most significant bits (high bits) AD1PCFG&amp;lt;31:16&amp;gt; are ignored, but AD1PCFG&amp;lt;15:0&amp;gt; determine which of the 16 pins is treated as an analog input.  0 indicates analog input, and 1 indicates DIO.  So if the bit AD1PCFG&amp;lt;7&amp;gt; is 0, then the pin with the function AN7 is an analog input; if AD1PCFG&amp;lt;7&amp;gt; is 1, then it is a DIO.  AD1PCFG resets to 0x0000, so all 16 pins of port B are treated as analog inputs by default.  To make AN15 and AN1 analog inputs and the rest DIO, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG = 0x7FFD&amp;lt;/tt&amp;gt;.  To make AN15 and AN1 analog inputs but leave the other settings unchanged, we can use the C command &amp;lt;tt&amp;gt;AD1PCFG &amp;amp;= 0x7FFD&amp;lt;/tt&amp;gt;.  Note we only have to specify 16 bits, or 4 hex digits, as the 16 most significant bits have no role.  Instead of acting on the entire SFR, we could instead address an individual bit, using &amp;lt;tt&amp;gt;AD1PCFGbits.PCFG15 = 1&amp;lt;/tt&amp;gt;, for example, to set the value of a single bit.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Lynch</name></author>
	</entry>
</feed>