<?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: Misbehaving Maple as Compiled Sketch Size Approaches 17000 Bytes</title>
		<link>http://forums.leaflabs.com/topic.php?id=181</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:24:59 +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=181" rel="self" type="application/rss+xml" />

		<item>
			<title>poslathian on "Misbehaving Maple as Compiled Sketch Size Approaches 17000 Bytes"</title>
			<link>http://forums.leaflabs.com/topic.php?id=181#post-1258</link>
			<pubDate>Tue, 14 Sep 2010 14:32:27 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1258@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;In general, RAM builds have become progressively less useful as libmaple gets more fleshed out. Most of the newer features are becoming &#34;optional&#34; in the sense that they get added as a library (like the Wire port in 0.0.7) or need to be manually instantiated (like HardwareSpi, which you cant use without doing:&#60;/p&#62;
&#60;p&#62;HardwareSpi spiPort;&#60;br /&#62;
spiPort.begin();&#60;/p&#62;
&#60;p&#62;etc. &#60;/p&#62;
&#60;p&#62;both of these techniques wont use up your memory unless you use them. Contrast this with SerialUSB, which eats up tons of memory even if you call SerialUSB.end() or never use a SerialUSB.print in your sketch at all.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>poslathian on "Misbehaving Maple as Compiled Sketch Size Approaches 17000 Bytes"</title>
			<link>http://forums.leaflabs.com/topic.php?id=181#post-1257</link>
			<pubDate>Tue, 14 Sep 2010 14:30:29 +0000</pubDate>
			<dc:creator>poslathian</dc:creator>
			<guid isPermaLink="false">1257@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hmm. Sounds like a stack overflow problem. Although the linker should guarantee some minimum stack size (1k i think) which is included in the final reported size of 16616B. However, I dont think this is enforced anywhere at runtime - except that you probably run the risk of a memory hardfault (throbbing). I cant quite glean from your code any reason that you would be thrashing your stack, however.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "Misbehaving Maple as Compiled Sketch Size Approaches 17000 Bytes"</title>
			<link>http://forums.leaflabs.com/topic.php?id=181#post-1178</link>
			<pubDate>Mon, 13 Sep 2010 10:40:42 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">1178@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Monday September 13, 2010&#60;/p&#62;
&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;In anticipation of running simple benchmarks on the upcoming Maple IDE-0.0.7 release I began to write simple sketches to &#34;automate&#34; the calculations.&#60;/p&#62;
&#60;p&#62;To test math functions I began by timing &#34;empty&#34; loops (which would return a millis() value greater than zero).&#60;/p&#62;
&#60;p&#62;Then I added similar loops which either did a simple floating point multiplication or floating point division.&#60;/p&#62;
&#60;p&#62;To my surprise, as the size of the compiled code approaches 17000 bytes (the &#34;limit&#34; of sketches uploaded to RAM) stranger things happen.&#60;/p&#62;
&#60;p&#62;16184 bytes: the sketch works&#60;br /&#62;
16560 bytes: error &#34;serial port already in use&#34;&#60;br /&#62;
16616 bytes: error &#34;throbbing LED&#34;&#60;/p&#62;
&#60;p&#62;Here is a more detailed summary of my testing.&#60;/p&#62;
&#60;p&#62;Restart Maple IDE-0.0.6&#60;/p&#62;
&#60;p&#62;Step 1)&#60;br /&#62;
compile: 16184 bytes [empty loop, multiplication]&#60;br /&#62;
upload:  sketch &#34;works&#34;&#60;/p&#62;
&#60;p&#62;Step 2): add the second set of multiplication tests&#60;br /&#62;
compile: 16560 bytes [empty loop, multiplication, multiplication]&#60;br /&#62;
upload:  after the IDE prints &#34;Resetting USB to switch back to runtime mode&#34; the Maple IDE reports &#34;Serial port already in use&#34;&#60;/p&#62;
&#60;p&#62;Restart Maple IDE-0.0.6&#60;/p&#62;
&#60;p&#62;Step 3): restore code to be same as Step 1&#60;br /&#62;
compile: 16184 bytes [empty loop, multiplication]&#60;br /&#62;
upload:  sketch &#34;works&#34;&#60;/p&#62;
&#60;p&#62;Step 4): add set of division tests (as expected, the code is slightly larger than Step 2)&#60;br /&#62;
compile: 16616 bytes [empty loop, multiplication, division]&#60;br /&#62;
upload:  after the IDE prints &#34;Resetting USB to switch back to runtime mode&#34; see throbbing LED.&#60;/p&#62;
&#60;p&#62;If I upload the code to FLASH memory the first three steps work.  However, when FLASH memory is used with the fourth step the IDE stops after the dreaded &#34;Starting download: [&#34; message.&#60;/p&#62;
&#60;p&#62;Any ideas?&#60;/p&#62;
&#60;p&#62;BTW, I know that printing of floating point values has improved in Arduino 0018 and 0019.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;Stephen from NYC&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
/*&#60;/p&#62;
&#60;p&#62; Created 11 September 2010, last updated 13 September 2010&#60;br /&#62;
 By leaflabs.com forums member &#34;Stephen from NYC&#34;&#60;/p&#62;
&#60;p&#62; This code is released under a Creative Commons Attribution-Share Alike 3.0 license.&#60;/p&#62;
&#60;p&#62;*/&#60;/p&#62;
&#60;p&#62;#define LIMIT 30&#60;/p&#62;
&#60;p&#62;#define COMM SerialUSB&#60;/p&#62;
&#60;p&#62;int totalloops=LIMIT*LIMIT*LIMIT*LIMIT; // four sets of nested loops&#60;/p&#62;
&#60;p&#62;int counter1=0;&#60;br /&#62;
int counter2=0;&#60;br /&#62;
int counter3=0;&#60;br /&#62;
int counter4=0;&#60;/p&#62;
&#60;p&#62;unsigned long empty=0;&#60;br /&#62;
unsigned long emptystart=0;&#60;br /&#62;
unsigned long emptystop=0;&#60;/p&#62;
&#60;p&#62;unsigned long floatmultiply=0;&#60;br /&#62;
unsigned long floatmultiplystart=0;&#60;br /&#62;
unsigned long floatmultiplystop=0;&#60;/p&#62;
&#60;p&#62;float a= 1.234567890;&#60;br /&#62;
float b=10.987654321;&#60;br /&#62;
float c=0;&#60;/p&#62;
&#60;p&#62;float rate=0.0;&#60;/p&#62;
&#60;p&#62;void setup()&#60;br /&#62;
{&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;void loop()&#60;br /&#62;
{&#60;br /&#62;
COMM.print(&#34;\n. . . . . . . . . . . .\n&#34;);&#60;/p&#62;
&#60;p&#62;COMM.println(&#34;\nEmpty: Start loops&#34;);&#60;/p&#62;
&#60;p&#62;emptystart=millis();&#60;/p&#62;
&#60;p&#62;for (counter1=0; counter1 &#38;lt; LIMIT; counter1++)&#60;br /&#62;
{&#60;br /&#62;
for (counter2=0; counter2 &#38;lt; LIMIT; counter2++)&#60;br /&#62;
{&#60;br /&#62;
for (counter3=0; counter3 &#38;lt; LIMIT; counter3++)&#60;br /&#62;
{&#60;br /&#62;
for (counter4=0; counter4 &#38;lt; LIMIT; counter4++)&#60;br /&#62;
{&#60;br /&#62;
// no calculation here&#60;/p&#62;
&#60;p&#62;if ((counter1==(LIMIT-1)) &#38;amp;&#38;amp; (counter2==(LIMIT-1)) &#38;amp;&#38;amp; (counter3==(LIMIT-1)) &#38;amp;&#38;amp; (counter4==(LIMIT-1))) COMM.println(&#34;Inner loop finished&#34;);&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;emptystop=millis();&#60;/p&#62;
&#60;p&#62;COMM.println(&#34;Stop loops&#34;);&#60;/p&#62;
&#60;p&#62;empty=emptystop-emptystart;&#60;/p&#62;
&#60;p&#62;COMM.print(&#34;empty: &#34;);&#60;br /&#62;
COMM.print(empty);&#60;br /&#62;
COMM.println(&#34;  milliseconds&#34;);&#60;/p&#62;
&#60;p&#62;// end of &#34;empty&#34; loops / / / / / / / / / / / / / &#60;/p&#62;
&#60;p&#62;COMM.println(&#34;\nMultiplication 1: Start loops&#34;);&#60;/p&#62;
&#60;p&#62;floatmultiplystart=millis();&#60;/p&#62;
&#60;p&#62;for (counter1=0; counter1 &#38;lt; LIMIT; counter1++)&#60;br /&#62;
{&#60;br /&#62;
for (counter2=0; counter2 &#38;lt; LIMIT; counter2++)&#60;br /&#62;
{&#60;br /&#62;
for (counter3=0; counter3 &#38;lt; LIMIT; counter3++)&#60;br /&#62;
{&#60;br /&#62;
for (counter4=0; counter4 &#38;lt; LIMIT; counter4++)&#60;br /&#62;
{&#60;br /&#62;
c=a*b;&#60;/p&#62;
&#60;p&#62;if ((counter1==(LIMIT-1)) &#38;amp;&#38;amp; (counter2==(LIMIT-1)) &#38;amp;&#38;amp; (counter3==(LIMIT-1)) &#38;amp;&#38;amp; (counter4==(LIMIT-1))) COMM.println(&#34;Inner loop finished&#34;);&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;floatmultiplystop=millis();&#60;/p&#62;
&#60;p&#62;COMM.println(&#34;Stop loops&#34;);&#60;/p&#62;
&#60;p&#62;floatmultiply=floatmultiplystop-floatmultiplystart;&#60;/p&#62;
&#60;p&#62;COMM.print(&#34;multiply: &#34;);&#60;br /&#62;
COMM.print(floatmultiply-empty);&#60;br /&#62;
COMM.print(&#34; milliseconds (for &#34;);&#60;br /&#62;
COMM.print(totalloops);&#60;br /&#62;
COMM.println(&#34; loops)&#34;);&#60;/p&#62;
&#60;p&#62;COMM.print(&#34;float multiplication rate: &#34;);&#60;/p&#62;
&#60;p&#62;rate=(floatmultiply-empty) * 1000 / totalloops;&#60;/p&#62;
&#60;p&#62;COMM.print(rate);&#60;/p&#62;
&#60;p&#62;COMM.println(&#34; microseconds per multiplication&#34;);&#60;/p&#62;
&#60;p&#62;// end of first multiplication / / / / / / / / / / / / / &#60;/p&#62;
&#60;p&#62;/*&#60;/p&#62;
&#60;p&#62;COMM.println(&#34;\nMultiplication 2: Start loops&#34;);&#60;/p&#62;
&#60;p&#62;floatmultiplystart=millis();&#60;/p&#62;
&#60;p&#62;for (counter1=0; counter1 &#38;lt; LIMIT; counter1++)&#60;br /&#62;
{&#60;br /&#62;
for (counter2=0; counter2 &#38;lt; LIMIT; counter2++)&#60;br /&#62;
{&#60;br /&#62;
for (counter3=0; counter3 &#38;lt; LIMIT; counter3++)&#60;br /&#62;
{&#60;br /&#62;
for (counter4=0; counter4 &#38;lt; LIMIT; counter4++)&#60;br /&#62;
{&#60;br /&#62;
c=a*b;&#60;/p&#62;
&#60;p&#62;if ((counter1==(LIMIT-1)) &#38;amp;&#38;amp; (counter2==(LIMIT-1)) &#38;amp;&#38;amp; (counter3==(LIMIT-1)) &#38;amp;&#38;amp; (counter4==(LIMIT-1))) COMM.println(&#34;Inner loop finished&#34;);&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;floatmultiplystop=millis();&#60;/p&#62;
&#60;p&#62;COMM.println(&#34;Stop loops&#34;);&#60;/p&#62;
&#60;p&#62;floatmultiply=floatmultiplystop-floatmultiplystart;&#60;/p&#62;
&#60;p&#62;COMM.print(&#34;multiply: &#34;);&#60;br /&#62;
COMM.print(floatmultiply-empty);&#60;br /&#62;
COMM.print(&#34; milliseconds (for &#34;);&#60;br /&#62;
COMM.print(totalloops);&#60;br /&#62;
COMM.println(&#34; loops)&#34;);&#60;/p&#62;
&#60;p&#62;COMM.print(&#34;float multiplication rate: &#34;);&#60;/p&#62;
&#60;p&#62;rate=(floatmultiply-empty) * 1000 / totalloops;&#60;/p&#62;
&#60;p&#62;COMM.print(rate);&#60;/p&#62;
&#60;p&#62;COMM.println(&#34; microseconds per multiplication&#34;);&#60;/p&#62;
&#60;p&#62;*/&#60;/p&#62;
&#60;p&#62;// end of second multiplication / / / / / / / / / / / / / &#60;/p&#62;
&#60;p&#62;/*&#60;/p&#62;
&#60;p&#62;// division&#60;/p&#62;
&#60;p&#62;COMM.println(&#34;\nDivision: Start loops&#34;);&#60;/p&#62;
&#60;p&#62;floatmultiplystart=millis();&#60;/p&#62;
&#60;p&#62;for (counter1=0; counter1 &#38;lt; LIMIT; counter1++)&#60;br /&#62;
{&#60;br /&#62;
for (counter2=0; counter2 &#38;lt; LIMIT; counter2++)&#60;br /&#62;
{&#60;br /&#62;
for (counter3=0; counter3 &#38;lt; LIMIT; counter3++)&#60;br /&#62;
{&#60;br /&#62;
for (counter4=0; counter4 &#38;lt; LIMIT; counter4++)&#60;br /&#62;
{&#60;br /&#62;
c=a/b;&#60;/p&#62;
&#60;p&#62;if ((counter1==(LIMIT-1)) &#38;amp;&#38;amp; (counter2==(LIMIT-1)) &#38;amp;&#38;amp; (counter3==(LIMIT-1)) &#38;amp;&#38;amp; (counter4==(LIMIT-1))) COMM.println(&#34;Inner loop finished&#34;);&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;br /&#62;
}&#60;/p&#62;
&#60;p&#62;floatmultiplystop=millis();&#60;/p&#62;
&#60;p&#62;COMM.println(&#34;Stop loops&#34;);&#60;/p&#62;
&#60;p&#62;floatmultiply=floatmultiplystop-floatmultiplystart;&#60;/p&#62;
&#60;p&#62;COMM.print(&#34;division: &#34;);&#60;br /&#62;
COMM.print(floatmultiply-empty);&#60;br /&#62;
COMM.print(&#34; milliseconds (for &#34;);&#60;br /&#62;
COMM.print(totalloops);&#60;br /&#62;
COMM.println(&#34; loops)&#34;);&#60;/p&#62;
&#60;p&#62;COMM.print(&#34;float diviion rate: &#34;);&#60;/p&#62;
&#60;p&#62;rate=(floatmultiply-empty) * 1000 / totalloops;&#60;/p&#62;
&#60;p&#62;COMM.print(rate);&#60;/p&#62;
&#60;p&#62;COMM.println(&#34; microseconds per division&#34;);&#60;/p&#62;
&#60;p&#62;*/&#60;/p&#62;
&#60;p&#62;}
&#60;/p&#62;&#60;/blockquote&#62;</description>
		</item>

	</channel>
</rss>
