<?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: Weird problem with LiquidCrystal and gcc optimization flag</title>
		<link>http://forums.leaflabs.com/topic.php?id=9997</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:07:28 +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=9997" rel="self" type="application/rss+xml" />

		<item>
			<title>funkysam on "Weird problem with LiquidCrystal and gcc optimization flag"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9997#post-21819</link>
			<pubDate>Tue, 01 Jan 2013 09:51:36 +0000</pubDate>
			<dc:creator>funkysam</dc:creator>
			<guid isPermaLink="false">21819@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I do not have objdump available on my Mac but I have 2 disas files generated with the makefile.&#60;br /&#62;
But those are more than 6000 lines long... rather intimidating...&#60;br /&#62;
There are definitely some differences, even in the vector tables.&#60;/p&#62;
&#60;p&#62;I've switched to a more simple lcd library that will get the job done in my case, but if someone wants to investigate the problem, I'll gladly post the 2 files.&#60;/p&#62;
&#60;p&#62;As for the optimization flag in the IDE, I searched for a solution two days ago and found nothing.&#60;br /&#62;
Apparently, this is hard coded.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Weird problem with LiquidCrystal and gcc optimization flag"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9997#post-21816</link>
			<pubDate>Mon, 31 Dec 2012 14:52:55 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">21816@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;funkysam - would you post the disassembler output of objdump of the (minimal) program compiled with -Os and -O1 (2 or 3) at, say, &#60;a href=&#34;http://pastebin.com/&#34;&#62;pastebin&#60;/a&#62; or &#60;a href=&#34;https://gist.github.com/&#34;&#62;github gist&#60;/a&#62;?&#60;br /&#62;
It is long shot, but someone might look at the differences and spot the change which may effect the LCD.&#60;/p&#62;
&#60;p&#62;A common cause of hardware failure is the difference in voltage; i.e. 5V for Arduino, and 3.3V for Maple. That's why it might be useful to know the precise LCD model.&#60;/p&#62;
&#60;p&#62;A possible cause of failure with differing optimisatios is the lack of a &#60;code&#62;volatile&#60;/code&#62; on a memory access. My initial reaction is the code for Arduino and Maple is being compiled by gcc, but there might be differences between versions, so I wouldn't rule that out.&#60;/p&#62;
&#60;p&#62;I don't know of a practical way to change optimisation flags when compiling with the IDE.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mikep on "Weird problem with LiquidCrystal and gcc optimization flag"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9997#post-21815</link>
			<pubDate>Mon, 31 Dec 2012 09:35:15 +0000</pubDate>
			<dc:creator>mikep</dc:creator>
			<guid isPermaLink="false">21815@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This is a long shot, but here it goes:&#60;br /&#62;
I have seen in some Arduino libraries that there is a &#34;delay&#34; function or something like that to generate the necessary delays when initializing the LCD.&#60;/p&#62;
&#60;p&#62;Sometimes this &#34;delay&#34; function is just implemented as a loop with no real statements in there.&#60;br /&#62;
Could it be that the compiler &#34;optimizes&#34; this loop away since no &#34;real&#34; work is performed in there?&#60;br /&#62;
Take a look at the LCD initialization code and see how the necessary delays are implemented.&#60;/p&#62;
&#60;p&#62;Just a thought,&#60;br /&#62;
Mike
&#60;/p&#62;</description>
		</item>
		<item>
			<title>funkysam on "Weird problem with LiquidCrystal and gcc optimization flag"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9997#post-21814</link>
			<pubDate>Mon, 31 Dec 2012 09:07:09 +0000</pubDate>
			<dc:creator>funkysam</dc:creator>
			<guid isPermaLink="false">21814@http://forums.leaflabs.com/</guid>
			<description>&#60;blockquote&#62;&#60;p&#62;
Is there a way to change the optimization flag when compiling from the Maple IDE?
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;Looks like it's not that easy... unfortunately...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>funkysam on "Weird problem with LiquidCrystal and gcc optimization flag"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9997#post-21812</link>
			<pubDate>Sun, 30 Dec 2012 04:46:21 +0000</pubDate>
			<dc:creator>funkysam</dc:creator>
			<guid isPermaLink="false">21812@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi gbulmer,&#60;/p&#62;
&#60;p&#62;No problem for the code edit - I just copy-pasted it from the arduino LiquidCrystal example and adapted it to Maple.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;What does &#34;the LCD does not seem to initialize&#34; mean?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Nothing happens, like when you power the LCD but do not connect the E/RS/Data lines.&#60;br /&#62;
Same with the code you suggested.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;What are the actual symptoms of failure? Is anything printed on the LCD? Is there some garbage on the screen? Is there an indication that the program is working at all? ...? Please give more detail and try to be specific.&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;Nothing is printed on the LCD, no garbage.&#60;br /&#62;
Apart from the LCD, the (much bigger than the above example) program does work perfectly (as if there were no LCD).&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Is it possible that it was working previously by 'good luck' and this is just showing up a bug which has always been lurking?&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;This is my first attempt at using it with the LiquidCrystal library.&#60;br /&#62;
I have used it (the lcd) before with an AVR with no problem, but was using another LCD library.&#60;/p&#62;
&#60;p&#62;BTW, I did not plan to use LiquidCrystal library at first, I just wanted to port the library I have used on AVR, but sometimes, it feels easier to use what's already there... and sometimes not... It took 15 minutes to port my AVR lcd library, and the LCD is working fine with it, both with -Os and -O1,2 or 3.&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;Do you know how to use objdump from binutils? You could objdump both the program compiled with -Os and -O1, and diff them. That would show which parts of the program are different (if you can read ARM assembler).&#60;/p&#62;
&#60;/blockquote&#62;
&#60;p&#62;I did quickly have a look at the disas files (though I don't speak assembly), from what I remember, there were differences in the generated code for the LiquidCrystal library, but this could be normal - as I am really not an assembly expert.&#60;/p&#62;
&#60;p&#62;Is there a way to change the optimization flag when compiling from the Maple IDE?&#60;br /&#62;
I'd like to test the difference in optimization flag there too...
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "Weird problem with LiquidCrystal and gcc optimization flag"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9997#post-21811</link>
			<pubDate>Sat, 29 Dec 2012 15:26:42 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">21811@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;funkysam - I edited your post so that the code looked a bit better; I hope that is okay.&#60;/p&#62;
&#60;p&#62;What does &#60;em&#62;&#34;the LCD does not seem to initialize&#34;&#60;/em&#62; mean? &#60;/p&#62;
&#60;p&#62;What are the actual symptoms of failure? Is anything printed on the LCD? Is there some garbage on the screen? Is there an indication that the program is working at all? ...? Please give more detail and try to be specific.&#60;/p&#62;
&#60;p&#62;Do you know how to use objdump from binutils? You could objdump both the program compiled with -Os and -O1, and diff them. That would show which parts of the program are different (if you can read ARM assembler).&#60;/p&#62;
&#60;p&#62;What LCD are you using?&#60;/p&#62;
&#60;p&#62;Is it possible that it was working previously by 'good luck' and this is just showing up a bug which has always been lurking?&#60;/p&#62;
&#60;p&#62;Edit:&#60;br /&#62;
Try to see if anything is working; maybe change loop to:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
  togglePin(13);
  delay(100);
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>funkysam on "Weird problem with LiquidCrystal and gcc optimization flag"</title>
			<link>http://forums.leaflabs.com/topic.php?id=9997#post-21808</link>
			<pubDate>Sat, 29 Dec 2012 08:44:32 +0000</pubDate>
			<dc:creator>funkysam</dc:creator>
			<guid isPermaLink="false">21808@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi everybody,&#60;/p&#62;
&#60;p&#62;I've started working on a maple board for 2 weeks now and I am facing a weird problem with the LiquidCrystal library.&#60;br /&#62;
I am using the command-line toolchain with libmaple 0.0.12.&#60;br /&#62;
The LCD is working fine with this basic arduino-like code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;lt;wirish/wirish.h&#38;gt;
// include the library code:
#include &#38;quot;./libraries/LiquidCrystal/LiquidCrystal.h&#38;quot;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(0,1,2,3,4,5);
void setup() {
  // set up the LCD&#38;#39;s number of columns and rows:
  lcd.begin(24, 2);
  // Print a message to the LCD.
  lcd.print(&#38;quot;hello, world!&#38;quot;);
}
void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}
// Force init to be called *first*, i.e. before static object allocation.
// Otherwise, statically allocated objects that need libmaple may fail.
__attribute__((constructor)) void premain() {
    init();
}
int main(void) {
    setup();
    while (true) {
        loop();
    }
    return 0;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;No problem, this is working as it should, so I guess everything is wired correctly.&#60;/p&#62;
&#60;p&#62;BUT if I change the optimization option flag in the makefile from -Os to -O1, 2 or 3, the LCD does not seem to initialize.&#60;br /&#62;
Any ideas why this is not working? Apart from this I did not face any other problem with switching the optimization flag from s to 1, 2 or 3.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
