<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Arduino-like low-level digitalWrite/Read</title>
		<link>http://forums.leaflabs.com/topic.php?id=74111</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:18:09 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=74111" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "Arduino-like low-level digitalWrite/Read"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74111#post-104879</link>
			<pubDate>Sun, 10 Nov 2013 23:31:30 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">104879@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I sketched some code a while ago for single bit changes which may be quicker, in the thread&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=737&#38;amp;page=2#post-25150&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=737&#38;amp;page=2#post-25150&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;and forum member tlgosser developed the ideas, and very helpfully posted links for the faster single bit change at&#60;br /&#62;
&#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=11844&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=11844&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;The ports on Maple's STM32F103 are 16 bits wide, and can be read and written 16 bits at a time.&#60;br /&#62;
We had a thread about a year ago experimenting with that. The documentation is the ST Micro manual 'RM0008' explains it all in detail (Chapter 9 &#34;General-purpose and alternate-function I/Os (GPIOs and AFIOs)&#34;)&#60;/p&#62;
&#60;p&#62;Essentially every GPIO port has a bunch of registers, with a wider range of capabilities than the Arduino's ATMega. &#60;/p&#62;
&#60;p&#62;Every GPIO port has 16bit wide input register and output register, so the whole port can be read or written in one access (2 cycles). The direction of the port's pins is set using two &#34;Port configuration registers&#34;, which supports a bit more than INPUT and OUTPUT. &#60;/p&#62;
&#60;p&#62;Every GPIO port has a register called &#34;Port bit reset register (GPIOx_BRR) (x=A..G)&#34; which can be used to clear any subset of the 16 pins to 0. Write a bit pattern with 1 bits in every pin position you want to clear is written to that register for the port.&#60;/p&#62;
&#60;p&#62;Further, every GPIO port has a register called &#34;Port bit set/reset register (GPIOx_BSRR) (x=A..G)&#34; which can be used to simultaneously clear a subset of the 16 pins to 0, and set a different subset of the ports 16 pins to 1.&#60;br /&#62;
One bits in the top 16 bits of a 32 bit word clear the corresponding port pin to 0, and ones in the lower 16 bits of the 32 bit word set the corresponding port pin to 1. Zero bits don't effect a pin.&#60;/p&#62;
&#60;p&#62;Some ports have fewer than 16 pins connected. You'll need to check the ST Micro datasheet for the STM32F103xB for the exact pin mapping.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>BlackBelt2025 on "Arduino-like low-level digitalWrite/Read"</title>
			<link>http://forums.leaflabs.com/topic.php?id=74111#post-104878</link>
			<pubDate>Sun, 10 Nov 2013 22:51:20 +0000</pubDate>
			<dc:creator>BlackBelt2025</dc:creator>
			<guid isPermaLink="false">104878@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;So I was perusing the Arduino forums, and I came across the low-level code to do really fast digital reads/writes. For reads, I can assign the value PIND to a variable to get a bit string of the value of all the digital pins in port D (For example, if all pins in port D are HIGH, then PIND==B11111111).  I can also using a bit string to set the values of all pins in a given port.  For example, PORTD = B11111111 to set pins 0-7 to HIGH.&#60;/p&#62;
&#60;p&#62;Does the Maple have this functionality?  I have been using the low-level gpio_write_bit() for my code, but it seems like I could make it faster by using a bit string to set/read the values of multiple ports at once rather than using the gpio functions in a loop.&#60;/p&#62;
&#60;p&#62;Any insight is appreciated.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
